[英]Run git command in Jenkins failing
GIT_COMMIT 正在返回 null,所以我尝试运行以下命令:
env.GIT_COMMIT = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
我现在收到以下错误:
fatal: not a git repository (or any of the parent directories): .git
我的 Jenkins 工作区中确实有我的 git 存储库。 我应该在哪里运行 shell 脚本? 我有多个阶段看起来像:
stage('Checkout GIT')
stage('Do something else')
stage('Do an other thing')
我一直在尝试在最后两个阶段之一中运行 shell 命令
您还可以通过将 git 命令包装到目录中来指定存储库的位置:
stage('Checkout repo') {
steps {
dir ("{env.WORKSPACE}/<path_to_repo>") {
script {
<your code here>
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.