I have a Jenkinsfile
that uses a branching strategy.
I have an if
statement in every stage
.
My release/*
conditional is not working. I want to have any release/*
branches deployed to a staging env.
Is there any other way?
if (env.GIT_BRANCH == 'master' || env.GIT_BRANCH == 'release/*' || env.GIT_BRANCH == 'develop')```
You can make use of a regular expression, since currently you are making a string comparison to literally release/*
, which is unlikely to ever return true.
Utilizing a regular expression arrives at:
if (env.GIT_BRANCH == 'master' || env.GIT_BRANCH ==~ /release\// || env.GIT_BRANCH == 'develop')
which will match on any branch that begins with release/
, which is what you are attempting to check for in the question.
You can find more information on Groovy regular expression operators in the documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.