「Jenkins Pipeline」- 接受构建通知,并拉取代码 @20210124

接收构建通知,并触发构建

使用 Gogs 服务

Gogs | Jenkins plugin

Gogs 是 Gitlab 的替代品,轻量级的 Git 仓库服务。Gogs 同样支持 Webhook 功能(即在仓库发生变更时,通知 Jenkins 构建)。

1)在 Jenkins 中,安装 Gogs 插件;
2)在 Jenkins 中,配置 Gogs Webhook / Use Gogs secret 密钥;
3)在 Gogs 中,添加 Webhook 配置,地址 http(s)://<jenkins-server>/gogs-webhook/?job=<jobname> 格式,并指定密钥即可;
4)在 Gogs 中,点击 Test Delivery 测试;

在 Jenkins Pipeline 中,拉取代码

使用 Git 拉取

1)安装 Git plugin 插件
2)拉取代码:

git(
   url: "http://git-server/user/repository.git", 
   branch: "master",
   credentialsId: "",       // 在 Jenkins 中配置的用户名和密码
   changelog: true,
   poll: false              // Fast Remote Polling / https://plugins.jenkins.io/git
)

相关文档

Pipeline Steps Reference/Git plugin

参考文献

WikiNotes/接受构建通知,并拉取代码
What is “workspace polling” in the context of Jenkins?

猜你喜欢

转载自blog.csdn.net/u013670453/article/details/113077177