简体   繁体   中英

How to name the custom workspace in Jenkins job with branch name triggered by Github webhook?

I have created a single job in Jenkins to be triggered by commit on any branches in the GitHub using Webhook.
I want to create a custom workspace for each job trigger with respective to the branch commit.

I Tried following options and could not achieve it. Appreciate for any help.

Job Name : Test_Clone

Used advance options in general section and tried below options to name the workspace dynamically.

  1. Test_Clone_${GIT_BRANCH} - always gives the branch name from previous build.
  2. Test_Clone_${ref} - tried to use ref as defined in GitHub webhook payload, with no result.

To achieve: Ex: Commit from GitHub branch release-2.13.0 , Jenkins should create workspace with name Test_Clone_release-2.13.0 .

You might try and setup

Then your Jenkins job would have the xml webhook payload in it, which you can analyze ( with jq ) and extract the ' ref ' which includes the branch name .

From there, I would call (chain) a second job with a " branch " parameter (unless you can write a pipeline DSL with Jenkins 2) with that branch name, in order for the second job to use a custom workspace name based on that parameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM