對于我的 ETL 腳本,我使用的是持續開發基礎設施:如果測驗作業流成功,則意味著可以將其推送到生產中,然后在夜間運行,如果測驗不成功,則不會推送更改,但是生產腳本仍在運行。
到目前為止,我每次成功更改時都會手動將我的測驗分支重新設定為我的主分支。我想自動執行此操作,以便在測驗管道作業完成并成功后,Jenkins 會自動將 master 分支重新設定為測驗分支并將其推送到遠程存盤庫。

這是我當前的 jenkins 管道代碼模型(Jenkinsfile_test):
def gv
pipeline {
agent any
stages{
stage("init") {
steps {
script {
gv = load "script.groovy"
}
}
}
stage("01_test1") {
when {
changeset "**/01_test1/**"
}
steps {
script {
gv.test1()
}
}
}
stage("02_test2") {
when {
changeset "**/02_test2/**"
}
steps {
script {
gv.test2()
}
}
}
}
post {
success {
echo "success"
withCredentials([usernamePassword(credentialsId: 'xxx',
usernameVariable: 'xxx',
passwordVariable: 'xxx')]){
sh "git checkout master"
sh "git rebase test"
sh("git push http://$username:$password@http://git-server/test.git test")
}
}
}
}
我嘗試了在這里找到的解決方案:Is it possible to Git merge / push using Jenkins pipeline
但它不起作用。我實際上不知道如何設定我的成功步驟。
以下是我在運行 jenkins 管道作業時遇到的錯誤:
Error when executing success post condition:
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Program Files
(x86)\Jenkins\workspace\test_pipeline")
任何幫助將非常感激。
uj5u.com熱心網友回復:
“'nohup' not found 錯誤”的主要原因看起來sh是 Windows 不支持該步驟。例如,您可以使用bat或安裝Cygwin。看到這個答案。
使用bat應該讓它像這樣作業:
post {
success {
echo "success"
withCredentials([usernamePassword(credentialsId: 'xxx',
usernameVariable: 'xxx',
passwordVariable: 'xxx')]){
bat "git checkout master"
bat "git rebase test"
bat("git push http://$username:$password@http://git-server/test.git test")
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/371285.html
上一篇:適用于Delphi10.4.1及更高版本的TEdgeBrowser:如何捕獲F12(OpenDevToolsWindow)?
