Search code examples
jenkinsjenkins-pluginsjenkins-pipelinejenkins-cli

Capturing branch in jenkins from post commit hook


I have created a post commit hook in BitBucket stash and any commits there is successfully invoking my jenkins pipeline job.

Below is the console log -

> git fetch --tags --progress https://onestash.myorg.com/scm/orgdx/my-services.git
+refs/heads/*:refs/remotes/origin/*

Checking out Revision 24gjj45kl4j54klj454k54 (origin/Sprint-11)

I want this branch origin/Sprint-11 to be captured in build parameter so that I can pass it as a parameter to downstream jobs that are triggered from this job.

How can I capture this branch to a parameter? Thanks in advance


Solution

  • GIT_BRANCH env variable is capturing it.