Promote all builds to master on Jenkins
-
23-12-2019 - |
문제
I'm using Jenkins for CI on my project. Right now, I have a "Dev" build, which is triggered by Stash (git server) any time a commit is made to any branch.
I'm trying to incorporate my release workflow as well. Here's the plan:
- Dev job uses the Promoted Builds plugin to promote all builds to
master
- Release job is triggered by the promotion of Dev
However, I can't seem to figure out how to promote a build based on its branch. I've tried the "promote immediately based on build parameters" and specified the GIT_BRANCH
to be origin/master
. When I run the build, I echo %GIT_BRANCH%
and it prints origin/master
when it's supposed to.
I also tried adding a string parameter BRANCH
to the build and set BRANCH=%GIT_BRANCH%
in my build script in case it actually needs to be a parameter rather than just an environment variable.
Still stumped.
해결책
Finally figured it out. Added a String build parameter called IS_RELEASE_CANDIDATE
with a default value of 0
. I'm using "Promote immediately once the build is complete based on build parameters" with the condition that IS_RELEASE_CANDIDATE
is 1
.
In my build steps, I've added a Conditional step using the Conditional BuildStep Plugin to be run when the strings $GIT_BRANCH
and stash/master
match.
If they match, I use the EnvInject Plugin to set IS_RELEASE_CANDIDATE=1
.