我有一种情况,只有上一次构建成功时,我才需要工作才能运行。
如果以前的构建失败,我需要用户等待管理员批准。
如果先前的版本成功,则用户可以运行该作业。
有人可以帮我怎么做。
下面是管道脚本,它将检查先前的构建,并在先前的构建失败或成功的情况下寻求批准
pipeline{
agent any
stages{
stage('Previous Status check'){
steps{
echo "Checking"
sleep 10
}
}
stage('Deploy approval'){
when {
expression {
// When last build has failed
!hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true
}
}
steps {
input(message: 'last build was failed please check target group and approve', ok: 'Release!' , submitter: "ritesh.mahajan")
}
}
stage('Building code on server'){
steps{
script {
def inputConfig
def inputTest
// Get the input
def userInput = input(
id: 'userInput', message: 'Enter the branch to build',
parameters: [
string(defaultValue: 'Master',
description: 'Enter the branch',
name: 'Branch'),
])
inputbranch=userInput
echo "${inputbranch}"
echo "here we can execute script in remote machine by default it will build master ..we can also accept parameter"
}
}
}
}
}