How can I unset an env variable in a Exec task?

I want to run git fetch on my source before building. I use a gradle Exec task for that. I have to unset GIT_SSH, because I don’t want, that git uses plink to fetch, but its own key provided by ssh-agent.

If I set an empty string, git fetch fails. If I set null, gradle crashes.

Is there a possibility to unset an env variable on a Exec task?

One option is to write a shell script that unsets the environment variable and runs Git, and invoke that script from the ‘Exec’ task. Another option might be to use one of the third-party Gradle SCM plugins to interact with Git.

Thanks for your answer. I forgot to add, that I had this problem on windows (plink is a ssh-agent alternative for tortoise git).

The script is a possible, but somehow ugly solution, since the project has to be cross platform compatible and I had to provide two different scripts for win and posix OS.

I also tried the gradle-git plugin, but the GitFetch task always popped up a jgit messagebox nagging about not knowing the git server, which makes it unusable for automatisation. SSH and git commandline didn’t emit such warnings.

If there is no better solution, I’ll probably just unset this variable before running gradle at all.