BAEL-5704:- Skip a stage in a Jenkins Pipeline (#13707)
This commit is contained in:
parent
50d78ab618
commit
211e5fbbe2
@ -0,0 +1,32 @@
|
||||
pipeline {
|
||||
agent any
|
||||
parameters {
|
||||
booleanParam(name: 'skip_test', defaultValue: false, description: 'Set to true to skip the test stage')
|
||||
}
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'echo "Building the application"'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
execute_stage('Test', params.skip_test)
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh 'echo "Deploying the application"'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def execute_stage(stage_name, skip) {
|
||||
stage(stage_name) {
|
||||
if(skip) {
|
||||
echo "Skipping ${stage_name} stage"
|
||||
return
|
||||
}
|
||||
// Add steps to test the application
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'echo "Building the application"'
|
||||
// Add steps to build the application
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
input message: 'Do you want to skip the test stage?', ok: 'Yes', parameters: [booleanParam(name: 'skip_test', defaultValue: false)], timeout: time(minutes: 5))
|
||||
script {
|
||||
if(params.skip_test) {
|
||||
sh 'echo "Testing the application"'
|
||||
return
|
||||
}
|
||||
}
|
||||
// Add steps to test the application
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh 'echo "Deploying the application"'
|
||||
// Add steps to deploy the application
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
jenkins-modules/jenkins-jobs/skip-stage-job/skip-when-script
Normal file
27
jenkins-modules/jenkins-jobs/skip-stage-job/skip-when-script
Normal file
@ -0,0 +1,27 @@
|
||||
pipeline {
|
||||
agent any
|
||||
parameters {
|
||||
booleanParam(name: 'skip_test', defaultValue: false, description: 'Set to true to skip the test stage')
|
||||
}
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'echo "Building application"'
|
||||
// Add build steps here
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when { expression { params.skip_test != true } }
|
||||
steps {
|
||||
sh 'echo "Testing application"'
|
||||
// Add test steps here
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh 'echo "Deploying application"'
|
||||
// Add deployment steps here
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user