0

I have the following code in my Jenkins pipeline script:

sh("alias git='/my/file/path/libexec/git-core/git'")
mvn "-e -X release:prepare"

The second line is calling git and it fails with:

The git-tag command failed.
Command output:
/bin/sh: git: command not found
Caused by: org.apache.maven.plugin.MojoFailureException: Unable to tag SCM

That shouldn't happen because I am aliasing it first.

My suspicion is that the statements are ran in different shells.

Is that true? In which case, how can I prevent this?

bsky
  • 19,326
  • 49
  • 155
  • 270

1 Answers1

1

Not sure what mvn is in your script (there is no built-in Maven function in Pipeline), but I think you want something like this:

sh '''
  export PATH=$PATH:/my/file/path/libexec/git-core/git
  mvn -e -X release:prepare
'''
amuniz
  • 3,292
  • 2
  • 20
  • 22
  • try `git status` instead of calling Maven, something else must be wrong in your build node. – amuniz Mar 06 '17 at 19:19
  • `git status` works. So I'm assuming the issue must come from Maven and the way it's calling Git. Maybe it's opening a subshell with no configuration and calling Git there, but I'm not sure. Do you have any idea? – bsky Mar 07 '17 at 14:24