在 Jenkinsfile 中使用 git fetch 时,使用 Jekinsfile 和“来自 SCM 的管道脚本”失败

在 Jenkinsfile 中使用 git fetch 时,使用 Jekinsfile 和“来自 SCM 的管道脚本”失败

我有一个 Jenkinsfile,里面有一个“git”命令来获取我的 java 服务的源代码。我还创建了一个带有“来自 SCM 的管道脚本”的作业来从 git 获取 jenkinsfile。但是,当使用某些特定命令(如 git show)来查找提交消息时,会发生失败。提交消息显示主管道的 git,而不是 Jenkinsfile 内部获取的 git

答案1

我终于自己找到了答案。当使用“来自 SCM 的管道脚本”运行 jenkins 以从 Git 获取 Jenkinsfile 时,我在该 Jenkinsfile 上使用的所有 git 命令都返回了当前 Git 获取。正如我所说,在 Jenkinsfile 中,我使用另一个 git 命令在 Jenkinsfile 中获取我的服务。为了获取 git 的 git 提交消息,我使用了以下命令。

git log --format=%H -n 1

相关内容