我有一個使用kubernetes代理的宣告式管道。
pipeline {
agent {
kubernetes {
yamlFile "file.yml" >。
}
}
... }
}
該管道由Gerrit觸發器啟動,GERRIT_REFSPEC引數由該觸發器提供。
在scm git checkout期間,第一次git fetch成功(GERRIT_RESPEC被識別),第二次失敗(GERRIT_RESPEC不被識別)。
由 Gerrit 觸發: https://[gerrit-server]
檢查 退出 git ssh。 //[gerrit-server]/[project] into [workspace] to read Jenkinsfile
選擇 Git 安裝 does not exist. 使用 默認 使用。
推薦的git工具是: NONE
使用 證書 gerrit
> git rev-parse resolve-git-dir [workspace] /. git # timeout=10 >。
獲取 變化 來自 the remote Git repository
> git config remote. origin.url ssh://[gerrit-server]/[project] # timeout=10。
Fetching upstream changes from ssh://[gerrit-server]/[project]
> git -version # timeout=10
> git --version # 'git version 2.30.2'/span>
使用 GIT_SSH 到 set credentials [gerrit-server]
> git fetch --tags--force --progress -- ssh: //[gerrit-server]/[project] refs/changes/11/1111/11:refs/changes/11/1111 # timeout=10
> git rev-parse refs/remotes/origin/refs/changes/11/1111^{commit} # timeout=10
> git rev-parse refs/changes/11/1111/11^{commit} #timeout=10
檢查 輸出 修訂 [修訂-id] (refs/changes/11/1111)
> git config core.sparsecheckout # timeout=10
> git checkout f [revision-id] # timeout=10
提交訊息: "[commit-message]"
第一次 時間 build. 跳過 changelog.
運行在耐用性級別: MAX_SURVIVABILITY
hudson.plugins.git. GitException: Command "git fetch --tags --force --progress --prune -- origin refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
stdout:
stderr: fatal: 無法 找到 remote ref refs/heads/$GERRIT_REFSPEC
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
at org.jenkinsci.plugins.workflow.multibranch.ReadTrustedStep$Execution.run(ReadTrustedStep.java:101)
at org.jenkinsci.plugins.workflow.multibranch.ReadTrustedStep$Execution.run(ReadTrustedStep.java:82)
at org.jenkinsci.plugins.workflow.step.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate2(ACL.java:449)
at hudson.security.ACL.impersonate(ACL.java:461)
at org.jenkinsci.plugins.workflow.step.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
完成: 失敗。
我已經看到一些其他的建議來禁用輕量級的結賬選項,但是在我的情況下這已經被禁用。
如果我使用節點標簽(節點被手動添加到Jenkins)而不是kubernetes,scm git checkout階段就會成功。
agent { label [physical-note-label] }
是否有辦法讓scm git checkout階段在Kubernetes代理中成功,而不把管道從宣告式改為腳本式?
所用版本:
- Jenkins: 2.303.1
- Kubernetes插件: 1.30.1
- Git插件: 4.8.2
- Gerrit trigger plugin: 2.34.0
uj5u.com熱心網友回復:
在起作用的 "git fetch "命令中,使用了如下引數:
refs/changes/11/1111/11:refs/changes/11/1111。
這就等于:
$GERRIT_REFSPEC:$GERRIT_REFSPEC
這才是執行獲取的正確方法。
但是在失敗的 "git fetch "命令中,使用了以下引數:
refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC。
這將被替換成:
refs/heads/refs/changes/11/1111/11:refs/remotes/origin/refs/changes/11/1111
這是完全錯誤的。
我不知道為什么會發生這種情況:-(
)uj5u.com熱心網友回復:
經過多次嘗試,我能夠通過在groovy中直接添加yaml內容而不是使用yamlFile來 "解決 "這個問題。我更希望把yaml放在外面,但由于這個錯誤,我不得不繼續把它放在里面。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/318096.html
標籤:
上一篇:如何在Jenkins中遞回地采集特定工件,同時排除一個子目錄?
下一篇:每一行的第一個字母要大寫
