Dha*_*tel 9 groovy heroku jenkins
所有人都知道任何关于让Jenkins与Heroku很好地玩的好文章吗?
我想做的事情:1)当签入开发者分支时,想要设置一个jenkins工作来轮询私人GitHub Repo.2)建立这个分支,确保一切都很好!3)将私有GitHub Repo代码库推送到Heroku Repo.所以它在Heroku上进行构建和部署.
我已经看过一些文章,但似乎无法完成整个流程.我已经尝试过GitHub插件和Heroku插件.我可以获得github插件来下拉和构建,但不明白如何推送到Heroku.Heroku插件允许我部署WAR文件,但这不会正确显示应用程序.所以我需要将代码库推送到Heroku Repo,以便进行编译和部署.
感谢:D
blo*_*tto 12
我使用Jenkins推送Heroku用于我们的应用程序.我没有使用Heroku插件,我喜欢'Execute Shell'给我的控件.这是一个相当详细的答案,如果我错过任何一定要评论.
1)轮询私人回购:
添加jenkins服务器的回调URL(让该页面保持打开状态以供日后使用).就像是 :
2)建立分支.确保设置了所有GitHub配置,因为只有在完成这些设置后,回调才会触发作业.
3)推送到Heroku.这里要考虑几件事.
Run Code Online (Sandbox Code Playgroud)heroku git:remote -a myApp git remote add heroku git@heroku.com:myApp.git
使用上面的内容创建一个Execute Shell脚本,仅用于第一次构建.
Run Code Online (Sandbox Code Playgroud)curl https://heroku.newrelic.com/accounts/ACCTID/applications/APPID/ping_targets/disable -X POST -H "X-Api-Key: APIKEY"
别忘了在以下之后再打开它:
Run Code Online (Sandbox Code Playgroud)curl https://heroku.newrelic.com/accounts/ACCTID/applications/APPID/ping_targets/enable -X POST -H "X-Api-Key: APIKEY"
Run Code Online (Sandbox Code Playgroud)heroku maintenance:on --app myApp heroku maintenance:off --app myApp
将这些放在一起,Jenkins上的典型部署脚本可能如下所示:
Run Code Online (Sandbox Code Playgroud)#one off to ensure heroku remote is added to repo heroku git:remote -a myApp git remote add heroku git@heroku.com:myApp.git #disbales curl https://heroku.newrelic.com/accounts/ACCTID/applications/APPID/ping_targets/disable -X POST -H "X-Api-Key: APIKEY" heroku maintenance:on --app myApp #push to heroku git push --force heroku master heroku run rake db:migrate --app myApp #enables curl https://heroku.newrelic.com/accounts/ACCTID/applications/APPID/ping_targets/enable -X POST -H "X-Api-Key: APIKEY" heroku maintenance:off --app myApp
小智 10
作为使用上面概述的Heroku API进行部署的替代方法,您只需将代码推送到远程Git存储库(即Heroku为您的应用程序定义的存储库)作为构建后操作.因此,您的工作将定义两个Git存储库 - 一个是您的Github存储库,另一个是Heroku存储库.

为Heroku存储库命名,例如'heroku',在Post-Build Actions部分中,使用Git发布者.请务必在目标远程名称字段中选择heroku名称.

根据您在Github项目上设置Build Trigger的方式,当构建完成时,Jenkins会将生成的快照推送到Heroku存储库,从而实现部署.
| 归档时间: |
|
| 查看次数: |
5660 次 |
| 最近记录: |