筹备工作

  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代码