我需要一個插件,如果管道可以移動到 Jenkins 的下一階段,團隊領導可以批準該插件。我計劃使用多階段管道(宣告性),所以在開發階段之后我需要一個人批準(只有他可以批準),開發人員可以運行這項作業。有沒有這樣的插件,只有一個人可以批準這樣的請求?
嘗試了基于角色的訪問插件,但這里沒有辦法控制可以進行階段批準的隔離人員
uj5u.com熱心網友回復:
@sidharth vijayakumar,我想您可以使用“管道:輸入步驟”插件。
據我了解,這個插件會暫停 Pipeline 執行,并允許用戶互動和控制構建流程。
引數輸入螢屏可以通過構建控制臺日志底部的鏈接或通過側邊欄中的鏈接訪問構建。
message 這個引數給出了一個提示,將顯示給人類:
Ready to go?
Proceed or Abort
如果單擊“繼續”,則構建將繼續下一步,如果單擊“中止”,則構建將中止。
您的管道腳本應該類似于下面的代碼片段
// Start Agent
node(your node) {
stage('Checkout') {
// scm checkout
}
stage('Build') {
//build steps
}
stage('Tests') {
//test steps
}
// Input Step
{
input message: 'Do you want to approve if flow can proceeded to next stage?', ok: 'Yes'
}
stage('Deploy') {
...
}
}
參考鏈接:https ://www.jenkins.io/doc/pipeline/steps/pipeline-input-step/
uj5u.com熱心網友回復:
為了解決基于角色的批準問題,我使用了帶有提交者的輸入塊。這意味著列為提交者的人將只能給予階段批準。
stage('Approval') {
agent none
steps {
script {
def deploymentDelay = input id: 'Deploy', message: 'Deploy to production?', submitter: 'rkivisto,admin', parameters: [choice(choices: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'], description: 'Hours to delay deployment?', name: 'deploymentDelay')]
sleep time: deploymentDelay.toInteger(), unit: 'HOURS'
}
}
}
請注意,提交者必須是有效用戶。使用基于角色的訪問插件并創建具有相關訪問權限的用戶。
腳本參考鏈接:https: //support.cloudbees.com/hc/en-us/articles/360029265412-How-can-I-approve-a-deployment-and-add-an-optional-delay-for-部署
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/476093.html
