2016-11-18 98 views
0

我在jenkins文件中有多參數化構建設置的分支管道。在Jenkins中是否有任何選項可以跳過具有參數步驟的Build,即用戶可以直接運行該作業。跳過在Jenkins中使用參數構建的選項

換句話說,用戶可以使用默認參數值構建作業,他們不需要訪問參數視圖。管理員可以使用Jenkins遠程API觸發器更改參數。

+0

這對瀏覽器UI,webhooks和REST API都應該是可能的。那些不適合你嗎? –

+0

@MattSchuchard:你能否詳細說明你的建議?我可以運行REST API並處理webhook。我對你講的瀏覽器用戶界面知之甚少。 –

回答

1

我終於找到了this插件來解決我的問題。

首先Jenkins文件必須配置這個隱藏參數插件。這將隱藏不需要從用戶端更改的參數。

jenkinsfile:

properties([[$class: 'ParametersDefinitionProperty', 
     parameterDefinitions: [ 
      [$class: 'WHideParameterDefinition', name: 'isValid', defaultValue: 'false'] 
     ] 
    ]]) 

二Git倉庫必須配置網絡掛接觸發詹金斯建立使用REST API。

2

還有另一種解決方案,不需要安裝額外的插件。

stage ('Setup') { 
    try { 
     timeout(time: 1, unit: 'MINUTES') { 
      userInput = input message: 'Configure build parameters:', ok: '', parameters: [ 
       [$class: 'hudson.model.ChoiceParameterDefinition', choices: 'staging\nproduction\nfree', description: 'Choose build flavor', name: 'BUILD_FLAVOR'], 
       [$class: 'hudson.model.ChoiceParameterDefinition', choices: 'Debug\nRelease', description: 'Choose build type', name: 'BUILD_TYPE'], 
       [$class: 'hudson.model.ChoiceParameterDefinition', choices: '4.1.12\n4.1.11\n4.1.10\n4.1.9\n4.1.8\n4.1.4\n3.5.5\n3.1.8\ncore\nOldVersion', description: 'Version Name', name: 'VERSION_NAME'], 
       [$class: 'hudson.model.ChoiceParameterDefinition', choices: 'origin/develop\norigin/hotfix/4.1.11\norigin/release/4.1.8\norigin/hotfix/4.1.7\norigin/hotfix/4.1.9\norigin/hotfix/4.1.10\norigin/release/4.1.6\norigin/release/4.1.5\norigin/hotfix/3.5.5', description: 'Git branch', name: 'GIT_BRANCH'], 
       [$class: 'BooleanParameterDefinition', defaultValue: false, description: 'Enable Gradle debug?', name: 'DEBUG'] 
     ] // According to Jenkins Bug: https://issues.jenkins-ci.org/browse/JENKINS-26143 
     } 
    } catch (err) { 
     userInput = [BUILD_FLAVOR: 'staging', BUILD_TYPE: 'Debug', VERSION_NAME: '4.1.12', GIT_BRANCH: 'origin/develop'] // if an error is caught set these values 
    } 
} 

可以定義一個超時供應參數部分,如果超時過期的任何條目已經插入了「捉」部分將設置默認參數,生成將啓動,無須用戶干預。