4

I'd like to know if there is something opposite to changeset in Jenkins. For example, in the doc (https://www.jenkins.io/doc/book/pipeline/syntax/), an example is given for changeset setting:

when { changeset pattern: ".TEST\\.java", comparator: "REGEXP" } or when { changeset pattern: "*/*TEST.java", caseSensitive: true } 

I'd like to know if I can set "changeset exclude" patterns so that the files match this pattern will not trigger certain stages.

2 Answers 2

3

You can use a negative lookahead regex pattern to create a changeset filter that excludes certain paths, for example:

when { changeset pattern: '^(?!.*\.TEST\.java).*', comparator: "REGEXP" } 
Sign up to request clarification or add additional context in comments.

Comments

1

I haven't tried it by myself, but surrounding the condition with not{} should do the trick:

when { not { changeset pattern: "*/*TEST.java", caseSensitive: true } } 

See Pipeline Syntax (when) (scroll down to not).

2 Comments

There is a problem doing it this way: If I have made multiple changes, both in the changeset and not in the changeset, then the stages will not execute(changeset become TRUE, not{} makes it FALSE, so the when condition will not meet). Any solution to work around it?
I don’t fully understand what you trying to archive, but you can combine multiple conditions with anyOf {} and allOf {} .

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.