
You can do it checking the changeset. Let's see some examples.
Suppose your repository has this structure:
nodejs-example
├── Dockerfile
├── configurations
│ ├── dev
│ │ └── config.yaml
│ └── prod
│ └── config.yaml
├── index.js
├── package.json
stage("Build step example") {
when{
changeset "index.js"
}
steps {
script {
sh 'npm i'
}
}
}
If you want to do a build step only if a file inside configurations folder changes, then do:
stage("Build step example") {
when{
anyOf{
changeset "configurations/**/*.yaml"
}
}
steps {
script {
sh 'npm i'
}
}
}
If you want to do a build step only if all the files in configurations folder change, then do:
stage("Build step example") {
when{
allOf{
changeset "configurations/**/*.yaml"
}
}
steps {
script {
sh 'npm i'
}
}
}
stage("Build step example") {
when{
not{
anyOf{
changeset "configurations/**/*.yaml"
}
}
}
steps {
script {
sh 'npm i'
}
}
}
No comments:
Post a Comment