Skip to content

Instantly share code, notes, and snippets.

@wololock
Last active April 1, 2023 15:30
Show Gist options
  • Save wololock/7c747d09e5e75bee8518143e8174a647 to your computer and use it in GitHub Desktop.
Save wololock/7c747d09e5e75bee8518143e8174a647 to your computer and use it in GitHub Desktop.
Jenkins Pipeline with matrix used for parallel deployments
pipeline {
agent any
stages {
stage("Deploy") {
matrix {
axes {
axis {
name "DEPLOY_ENVIRONMENT"
values "DEPLOY_DEV", "DEPLOY_STAGING", "DEPLOY_PROD"
}
}
stages {
stage("Deploy") {
when {
beforeAgent true
expression {
params[DEPLOY_ENVIRONMENT] == true
}
}
steps {
echo "Deploying to $DEPLOY_ENVIRONMENT"
}
}
}
}
}
}
}
@paul-uz
Copy link

paul-uz commented Aug 18, 2022

Are the axis input checkboxes a BlueOcean thing? If I setup a similar pipeline in Jenkins, I don't get to select the axis values I want to use, it just runs the stages for every value.

@wololock
Copy link
Author

@paul-uz That might be the Blue Ocean UI feature only, I haven't been using Jenkins for a while, so I can't tell you 100%.

@paul-uz
Copy link

paul-uz commented Aug 18, 2022

@paul-uz That might be the Blue Ocean UI feature only, I haven't been using Jenkins for a while, so I can't tell you 100%.

I dreaded as much! I just want to have multi-configurable pipelines 😂

@jairov-apptio
Copy link

the script is missing the input parameter line

@paulcanning
Copy link

the script is missing the input parameter line

Can you share the missing part?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment