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.
Test_Clone_${GIT_BRANCH}
- always gives the branch name from previous build. 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 a webhook url (on GitHub side) of:
http://<<yourserver>>/job/<<yourjob>>/buildWithParameters?token=<<yourtoken>>
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.