문제

I want to send a mail after a promotion is successful with the build details. How do I access $GIT_BRANCH variable in the mail?
From here, I get to know that we can use $GIT_BRANCH variable during build, but as the promotion step is after the build, I am unable to use this variable.

도움이 되었습니까?

해결책

I do not know how to do what you ask but I can tell you how I solved the same problem:

In the job that has the promotion, at the end of the build I execute

echo $GIT_BRANCH > git_branch

and I archive git_branch as a build artifact.

When a build of this job gets promoted, the promotion process triggers another job.

In this other job I use the Copy Artifact build step to get the file git_branch from the promoted job. In "Which build" I configure "Specified by permalink" and as Permalink "Latest promotion:(name of promotion)"

The added benefit of this approach is that whatever actions I want to take, I can do them in a separate workspace of a separate job. As you may know, the promotion runs asynchronously and uses the workspace of the promoted job, so there is no guarantee the workspace exists or what the contents of the workspace are. Doing anything there might even conflict with another build currently running. It is much safer to do promotion-related actions in the context of another job.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top