I configured my jenkins job (freestyle) with dev/test/prod environments using choice parameter with "This project is parameterised" option form jenkins job configuration.
I have setup webhook in my github soouce as https://myjenkins/github-webhook/ . when i commit a change to github repo, it is triggering build in jenkins always with "dev" environment option. how to make it to choose any of the other environment, based on my requirement?
I googled but didn't find correct answer. can someone help me?
Use some branch strategy and in your job do something like:
IF BRANCH == DEVELOPMENT
deploy to dev
IF BRANCH endsWith SNAPSHOT
deploy to dev
IF BRANCH == MASTER
deploy to production
ETC ...
When a developer perform a git push to Github, Bitbucket or Gitlab, these platforms send a Json to your continuous integration server(jenkis, travis,etc) with a lot of information related to the push event. Most important are:
Then in your continuous integration server you must parse this Json to get important values. In jenkis there are several plugins like: Generic webhook, easy webhook plugin , github plugin, etc
After of values extraction you can apply simple or complex validations using branch name, commit message, commit author, etc. For instance:
Your imagination is your only limitation.
Useful links:
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.