jenkins - Jenkins Pipeline:如何轮询管道中的特定分支
问题描述
我正在研究 Jenkins,我正在定义一个管道。在管道中,我有一个代码构建阶段,它将为我编译项目。我需要为特定分支(开发)轮询 SCM。我无法弄清楚如何使用轮询来做到这一点。我无法使用 webhook,因为我们的 Jenkins 实例位于公司网络后面,无法通过 github 访问。如果从 Jenkins 打开连接,那么是的,github 可以交谈。
我在构建触发器中看不到任何分支选项。我在管道中遗漏了什么吗?
所以这些是构建触发器。我推动了发展,但民意调查日志显示没有推动任何事情。我如何轮询开发?谢谢你。
在管道脚本中,我还添加了轮询机制,但没有运气:
stage('Preparation') {
git (
poll: true,
branch: 'origin/develop',
credentialsId: 'ID',
url: 'https://github.com/company/reponame.git'
)
}
解决方案
你的 jenkinsfile 应该是这样的
pipeline {
agent any
triggers {
cron('*/30 * * * *') <-----This will run every 30 min and will pull
}
stages {
stage('Git Checkout') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: "*/yourbranchname"]], <----This branch
doGenerateSubmoduleConfigurations: false,
submoduleCfg: [],
userRemoteConfigs: [
[credentialsId: "ID",
url: "yourgitrepo url"
]
]
])
}
}
}
推荐阅读
- node.js - 在 ubuntu 客户端中安装节点 js 是否与将其安装为服务器相同?
- javascript - iframe父窗口(window.top/window.parent)调用函数(规避跨域对象访问安全)
- javascript - 未使用 JavaScript 填充的列表
- typo3 - 将自定义模板文件添加到typo3 新闻扩展
- java - Java - 非空参数的声纳空传递
- c - 在安装库时链接 C 和 Fortran 时出错
- python - Perforce 后用户编辑触发器不起作用,用作用户前编辑
- elasticsearch - 发送文档和在柜台实际看到它们之间的延迟
- javascript - javascript window.print
- c# - System.OutOfMemoryException 自 WIndows IoT Core 构建 10.0.17763.737