我正在Jenkins上工作,我正在其中定义管道。在管道中,我有一个代码构建阶段,它将为我编译项目。我需要轮询SCM的特定分支(开发)。我无法弄清楚如何使用轮询。我无法使用webhooks,因为我们的Jenkins实例位于Company Network后面,无法通过github访问。如果从Jenkins打开了连接,那么可以,github可以讲话。
我在构建触发器中看不到任何分支选项。我在管道中缺少什么吗?
这些是构建触发器。我努力推动开发,但是民意测验记录表明没有任何努力。我该如何调查发展?谢谢。
在管道脚本中,我还添加了轮询机制,但是没有运气:
stage('Preparation') {
git (
poll: true,
branch: 'origin/develop',
credentialsId: 'ID',
url: 'https://github.com/company/reponame.git'
)
}
答案 0 :(得分:0)
您的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"
]
]
])
}
}
}