docker利用WebHook实现持续集成

2020-06-17 06:54:19易采站长站整理

    然后再看.ssh目录,多了一个known_hosts 里面有码云了,然后再手动构建,应该就能成功了

  至此,手动打包并部署就已经实现了

  ——————————自动部署 ————————————————–

  1. 安装上述插件后勾选Generic Webhook Trigger 增加post参数 ref  expression值为 $.ref   注意有个点

  增加optional filter

  其实上面这部分不用设置也行,尤其是只会在jenkins中部署一个项目的一个分支时,只需要勾选上Generic Webhook Trigger就可以的

  2. 在码云中增加hook:http://USER ID:API TOKEN@jenkins部署的地址:端口号/jenkins/generic-webhook-trigger/invoke (红色这部分不要变)

    (这里不用api token 直接用jenkins的登录密码也可以, api token查看地址为:jenkins-用户-点击用户名-api token)

    同时勾选push或者其他你认为需要触发部署的事件

  提交后点击测试,如果返回ok,则表示成功,切换到jenkins,查看项目是否能够自动部署

  我自己写了一个接口用来获取点击测试后,到底请求了些什么  

    格式化下内容如下:


{
"hook_name": "push_hooks",
"total_commits_count": 1,
"before": "0000000000000000000000000000000000000000",
"user_name": "肖哥哥",
"project": {
"path": "ci-demo",
"git_svn_url": "svn://gitee.com/xiaochangwei/ci-demo",
"path_with_namespace": "xiaochangwei/ci-demo",
"name": "ci-demo",
"namespace": "xiaochangwei",
"default_branch": "master",
"git_http_url": "https://gitee.com/xiaochangwei/ci-demo.git",
"name_with_namespace": "肖哥哥/ci-demo",
"url": "https://gitee.com/xiaochangwei/ci-demo",
"git_ssh_url": "git@gitee.com:xiaochangwei/ci-demo.git"
},
"repository": {
"name": "ci-demo",
"description": "",
"url": "https://gitee.com/xiaochangwei/ci-demo.git",
"homepage": "https://gitee.com/xiaochangwei/ci-demo"
},
"commits_more_than_ten": false,
"ref": "refs/heads/master",
"password": "",
"commits": [{
"author": {
"name": "肖哥哥",
"time": "2015-11-06T13:21:07+08:00",
"email": "317409898@qq.com"
},
"id": "ec7159240a346fa5988913aa3057b902a4acb126",