[英]parameterized jenkins build with github webhooks
I configured my jenkins job (freestyle) with dev/test/prod environments using choice parameter with "This project is parameterised" option form jenkins job configuration. 我在jenkins作业配置中使用带有“此项目已参数化”选项的选择参数,在dev / test / prod环境中配置了我的jenkins作业(自由式)。
I have setup webhook in my github soouce as https://myjenkins/github-webhook/ . 我在github源中将webhook设置为https:// myjenkins / github-webhook / 。 when i commit a change to github repo, it is triggering build in jenkins always with "dev" environment option. 当我对github repo进行更改时,它总是使用“ dev”环境选项触发jenkins中的构建。 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. 当开发人员对Github,Bitbucket或Gitlab执行git push时,这些平台会将Json发送给Json到您的持续集成服务器(jenkis,travis等),其中包含与push事件相关的大量信息。 Most important are: 最重要的是:
Then in your continuous integration server you must parse this Json to get important values. 然后,在您的持续集成服务器中,您必须解析此Json以获得重要的值。 In jenkis there are several plugins like: Generic webhook, easy webhook plugin , github plugin, etc 在jenkis中,有几个插件,例如:通用webhook, easy webhook插件 ,github插件等。
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: 有用的链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.