How downstream job uses the git commit that is passed by upstream job?

Jenkins Git plug-in is an intelligent tool. No specific configuration is needed. In upstream job trigger the downstream job with the Git commit used by the upstream job, downstream will automatically checkout the commit passed in by upstream.


It seems that now (Parameterized trigger 2.37, Jenkins 2.204), "trigger parameterized build" has the option to "Pass-through Git Commit that was built". Working even without any special configuration in the downstream job. Similar question


I had this same question. The core problem seems to be that Jenkins doesn't carry over build-time variables from the upstream job to the downstream job by default. So the GIT_COMMIT variable will be blank, unless you actually add the repository definition in the downstream job in the Source Code Management section. And from what I can tell, it does fetch the upstream git hash from the repo, so it's not just getting latest.

This was definitely a frustrating point and took me way too long to resolve.