I am trying to set up a series of jobs in Jenkins to build and deploy an application using the Promoting plug in. We are currently using Git as our SCM and we are using the Git Plug in to help with the builds. This particular build is a Maven build. The steps I am trying to implement is as follows:
- A build job that compiles, runs unit test and creates artifacts. This
job fires on code commit.
- The build job has a manual promotion point
to deploy this code into our test environment. The promotion point
has an approval parameter to pass the environment to be used for the
deployment.
- The promotion point triggers a job, let's call it the
Integration job, which only triggers several deployment jobs, some of
these deployment jobs require to get from Git the same code that was
used for building the artifacts. Since the code may have changed from
the moment this particular release was built to the moment we want
to do the deployment, I am trying to use the GIT_COMMIT environment
variable to propagate the commit number used to build the artifacts.
- In the Integration job, in the build step that triggers the specific
deployment job, I am not adding any parameters at all, not the Git,
not the "current build" ones.
The problem is the deployment job never gets the GIT_COMMIT value. So it is always failing while trying to retrieve the code from Git.
- On the build job, in the promotion process, besides the Approval parameter to select the environment, in the Action triggering the integration job I have added the "Current build parameters" and "Pass-through Git Commit that was built" parameters.
- On the build job, after it runs I can see the environment variables for the job and the GIT_COMMIT variable has the proper value for the commit.
- On the integration job I don't see the GIT_COMMIT in the environment variables list.
- On the deployment job I don't see the GIT_COMMIT in the environment variables list.
So far I have tried:
- Add "Current build parameters" and "Pass-through Git Commit that was built" to the trigger to the deployment job
- Adding another variable in the Build job and assign it the $GIT_COMMIT as a value
- Adding another variable as an Approval parameter for the promotion and give it $GIT_COMMIT value
- Adding another variable in the Trigger for the Integration job and give it $GIT_COMMIT value
- Adding a parameter to the deployment job and default it to $GIT_COMMIT, but overriding said parameter with the value from the trigger.
So far, no luck.
I must add that all the other parameters and variables are propagating properly, the Deployment environment one, I have one for versioning, BUILD_NUMBER, etc. everything propagates well, except for GIT_COMMIT.
I also have a similar setup for another application, this is a Grails application, and the GIT_COMMIT propagates perfectly fine there.
These are the versions I am using:
- Jenkins 1.632
- Git Plugin 2.4.0
- Promoted Builds (Simple) 1.9
- promoted builds plugin 2.24
- Java Open JDK 1.7.0_75
Any ideas are more than welcome. Thank you.
I was able to get a workaround, but I didn't find a solution for the original issue. The original issue is the GIT_COMMIT is not being propagated to the deployment job and I was unable to make that work. Instead, to have my process working I did the following:
On the build job, in the promotion process, when triggering the integration job I added "Predefined parameters" with the value: BUILD_COMMIT=${GIT_COMMIT}.
On the integration job, when triggering the deployment job, I am adding a "Current build parameters" parameter.
On the deployment job, in the git configuration, in the "Branches to build" field I am using ${BUILD_COMMIT}.
This is triggering all correctly and the deployment job is getting the proper commit number when deploying.
I hope this helps.