运行 git Jenkins 中的命令失败
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
我的 git 存储库在我的 Jenkins 工作区中。我应该在哪里 运行 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>
...
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
我的 git 存储库在我的 Jenkins 工作区中。我应该在哪里 运行 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>
...