jenkinsci / pipeline-github-plugin

Pipeline: GitHub
https://plugins.jenkins.io/pipeline-github/
MIT License
159 stars 73 forks source link

Individual "not" conditions seem to have different beahviour than grouping it #113

Closed roDew closed 2 years ago

roDew commented 2 years ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

What Operating System are you using (both controller, and any agents involved in the problem)?

...

Reproduction steps

Hi guys,

I'm creating a pipeline that has a condition like that:

            stage('Create, tag, scan and push the Docker image') {
               when {
                 //1st condition
                   anyOf {
                       expression { return params.PARAM1 }
                       expression { return params.PARAM2 }
                 //2nd condition
                       allOf {
                           branch 'release/**'
                           expression { env.VARIABLE == 'something' }
                       }
                 //3rd condition
                       allOf {
                           not { branch('release/**') }
                           not { changeRequest() }
                       }
                   }
               }
               steps {
                   someCustomMethod(...)
               }
            }

Expected Results

I would expect that my method is executed when the branch is not release and when there is not a PR, but it is all the time being executed.

Actual Results

I changed the code by:

                       not {
                           anyOf { 
                               branch('release/**')
                               changeRequest()
                           }
                       }

and it seems to work as I was expected with the branch, but "changeRequest" seems to ignore the setting of the CHANGE_NAME I'm doing: addEnvVar('CHANGE_BRANCH', 'develop')

Is this a bug or am I missing anything?

Anything else?

No response

roDew commented 2 years ago

Wrong repo, sorry