hrmpw
I'm open to discussion of how it should look, but I think we need some form of this.
"Right now the use case described is easily done as shown."
Yes, like I said, for simple expressions things are fine, but for complex expressions this would get unwieldy very fast.
stages {
stage ('Full Build') {
when {
expression {
GIT_BRANCH = 'origin/' + sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
return GIT_BRANCH == 'origin/master' || params.FORCE_FULL_BUILD
}
}
}
stage ('Incremental Build') {
when {
expression {
GIT_BRANCH = 'origin/' + sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
return !(GIT_BRANCH == 'origin/master' || params.FORCE_FULL_BUILD)
}
}
}
}
Then repeat that condition over and over for other stages. Mediocre.
I see your point about the specific `stage {}` condition syntax I described being not great, but I also don't want to use general comparison operators if we can avoid them here. Also, stages run in serial and failure in a previous stage would generally stop the pipeline right?
Maybe this:
stages {
stage ('Full Build') {
when {
expression { return params.FORCE_FULL_BUILD }
}
}
stage ('Incremental Build') {
when {
stages('Full Build').skipped
}
}
stage ('Full Tests') {
when {
stages('Full Build').executed
}
}
stage ('Incremental Tests') {
when {
stages('Incremental Build').executed
}
}
}
Or we could follow your status example:
stages {
stage ('Full Build') {
when {
expression { return params.FORCE_FULL_BUILD }
}
}
stage ('Incremental Build') {
when {
stages('Full Build').skipped
}
}
stage ('Full Tests') {
when {
stages('Full Build').succeeded
}
}
stage ('Incremental Tests') {
when {
stages('Incremental Build').succeeded
}
}
}
I don't like this syntax formatting.
When I see this :
I read it as when this Stage is not "Full Build". My first reaction is that is always true.
If we want to say it is dependent in someway then we need to make that relationship explicit. When stage "Full Build" is not what? Not skipped, not run, not stable? That isn't clear.
Right now the use case described is easily done as shown. To me that is much more clear than the alternative. We can explore having some stage conditions but they need to be clear.
Maybe something like:
Or
Or