关于jenkins:JenkinsPipeline通过Gogs-Webhooks构建

5次阅读

共计 680 个字符,预计需要花费 2 分钟才能阅读完成。

筹备工作

  1. 插件

    • Git plugin
    • Maven Integration plugin
    • Gogs plugin
  2. 全局配置 (Global Tool Configuration)

    • Git
    • Maven
  3. 认证治理(Manage Credentials)

    • Jenkins 全局 Git SSH 密钥治理

      Notes: 此时 ID 为 gogs,前面会用到

    配置 Pipeline Item

  4. Gogs Webhookds

    • 应用 Gogs 平安密钥(Use Gogs Secret)
  5. 构建触发器(Build Triggers)

    • 当 Gogs 有扭转告诉时构建(Build when a change is pushed to Gogs)
  6. Pipeline

    • 抉择 Pipeline script,内容如下:
    pipeline {
     agent any
     stages {stage('Source') {
             steps {git branch: "master",credentialsId:"gogs", url: "{ 你的 Git 我的项目近程地址}.git"
             }
         }
         
     }
    }

    Notes: credentialsId 为之前配置的 gogs
    当有 Gogs 告诉过去时,从 Git 拉取近程代码到本地工作空间

    Gogs 配置

  • Payload URL:有 PUSH 时告诉的地址,即 Jenkins 的 Gogs 插件接管地址,格局为

    • http(s)://<< jenkins-server >>/gogs-webhook/?job=<< jobname >>
  • Secret:同 Jenkins Item 内配置
  • Test Delivery:能够测试与 Jenkins 联通性,当点击该按钮,能够看到告诉的后果,如果告诉胜利,Jenkins 相应的 Item 将会运行 Pipeline 代码
正文完
 0