Git 防止Jenkins管道命令在不同的shell中执行
我的Jenkins管道脚本中有以下代码:Git 防止Jenkins管道命令在不同的shell中执行,git,shell,maven,jenkins,jenkins-pipeline,Git,Shell,Maven,Jenkins,Jenkins Pipeline,我的Jenkins管道脚本中有以下代码: sh("alias git='/my/file/path/libexec/git-core/git'") mvn "-e -X release:prepare" 第二行正在调用git,失败原因如下: The git-tag command failed. Command output: /bin/sh: git: command not found Caused by: org.apache.maven.plugin.MojoFailureExcept
sh("alias git='/my/file/path/libexec/git-core/git'")
mvn "-e -X release:prepare"
第二行正在调用git
,失败原因如下:
The git-tag command failed.
Command output:
/bin/sh: git: command not found
Caused by: org.apache.maven.plugin.MojoFailureException: Unable to tag SCM
这不应该发生,因为我先给它取别名
我怀疑这些陈述是在不同的外壳中运行的
这是真的吗?
在这种情况下,我如何防止这种情况发生?不确定脚本中有什么
mvn
(管道中没有内置的Maven函数),但我认为您需要这样的功能:
sh '''
export PATH=$PATH:/my/file/path/libexec/git-core/git
mvn -e -X release:prepare
'''
您是否尝试过:mvn-Dgit=path/to/git-e-X发布:prepare?是的。同样的错误。你能提供pom文件吗?我认为它与
pom.xml
没有任何联系,因为它没有任何git插件或依赖项。那么错误是由maven引起的这一事实呢?尝试git status
而不是调用maven,你的构建节点中一定有其他错误。git status
有效。所以我假设这个问题一定来自Maven和它对Git的调用方式。也许它正在打开一个没有配置的子shell并在那里调用Git,但我不确定。你知道吗?