是否可以检查和更改jenkins管道中的参数?



我有jenkins管道,这将由非技术人员触发,技术人员将批准或拒绝此构建。所以我的问题是,在流程中,技术人员应该更改/填充一些空的参数(非技术人员可能不知道或忘记输入)。

stage 'Waiting Approval'
currentBuild.displayName = "Waiting for Approvel:" + name
timeout(time: 5, unit: 'DAYS')
        {
            input message: "Do you approve creating new user("+ name +")?", ok: 'Approve', submitter: 'Bilisim'
        }
// ########### STEP For Checking Missing or Wrong Parameters & Correct Them !!!! ##############
node('domainController') {
    stage 'Create New User'
    currentBuild.displayName = "Creating AD User:"+name
    build job: 'Create New AD User', parameters: [string(name: 'groups', value: groups), string(name: 'emailAdd', value: emailAdd), string(name: 'name', value: name), string(name: 'surname', value: surname), string(name: 'title', value: title), string(name: 'department', value: department), string(name: 'manager', value: manager), string(name: 'company', value: company), string(name: 'streetAdd', value: streetAdd), string(name: 'city', value: city), string(name: 'state', value: state), string(name: 'country', value: country), string(name: 'pcode', value: pcode), booleanParam(name: 'sendMail', value: sendMail.toBoolean()), booleanParam(name: 'details', value: details.toBoolean()), string(name: 'ou', value: ou)]
    currentBuild.displayName = "Finished Creating User:" + name
}

Jenkins管道参数作为变量传递给你的管道,所以你可以更新你的变量值。我不认为你真的可以在构建视图中"改变"一个参数,但是你可以等待技术人员的输入,并在需要时替换非技术人员的参数。

的例子:

stage "Stage 1"
echo "Non-technical person parameter : ${name}"
stage "Waiting approval"
timeout(time: 5, unit: 'DAYS') {
  def technicalApprovedUser = input id: 'input_approved_name' message: "Do you approve creating new user("+ name +")?", ok: 'Approve', submitter: 'Bilisim', parameters: [[$class: 'StringParameterDefinition', defaultValue: "${name}", description: '', name: 'User Name']]
}
stage 'Create New User'
currentBuild.displayName = "Creating AD User:"+technicalApprovedUser
build job: 'Create New AD User', parameters: [string(name: 'groups', value: groups), string(name: 'emailAdd', value: emailAdd), string(name: 'name', value: technicalApprovedUser), string(name: 'surname', value: surname), string(name: 'title', value: title), string(name: 'department', value: department), string(name: 'manager', value: manager), string(name: 'company', value: company), string(name: 'streetAdd', value: streetAdd), string(name: 'city', value: city), string(name: 'state', value: state), string(name: 'country', value: country), string(name: 'pcode', value: pcode), booleanParam(name: 'sendMail', value: sendMail.toBoolean()), booleanParam(name: 'details', value: details.toBoolean()), string(name: 'ou', value: ou)]
currentBuild.displayName = "Finistère Creating User:" + technicalApprovedUser

相关内容

  • 没有找到相关文章

最新更新