[英]Jenkins pipeline: poll SCM from a different agent
我正在研究必须在Linux从属代理/节点上运行的Jenkins管道(Windows主管道)。 我想基于轮询git存储库开始这项工作,但是由于防火墙配置,该存储库仅在从属节点中可见。
管道使用“ agent {node {label'xxx'}}”声明在正确的从属服务器上运行。 但是,轮询日志显示,所有轮询回购协议的尝试似乎都来自主数据库。 有没有办法从从节点轮询git repo? 可以更改防火墙配置,但是由于我们的IT安全组织,所以不方便。
由于没有更好的选择可立即出现,因此,这是我的详细解决方法。 该“ GitPoller”作业被配置为每隔10分钟运行一次。 它在目标代理(对git SCM服务器具有可见性)上运行,并执行git checkout并检查新的变更集。 如果找到任何变更集,则它将运行实际的构建作业。
pipeline {
agent {
node {
label 'xyzzy' /* run on the firewalled machine */
}
}
/* Declare the pipeline stages */
stages {
/* The "ScmFetch" stage fetches the baseline from git */
stage('ScmFetch') {
steps {
echo 'Fetching from SCM...'
/* Fetch the baseline from git */
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'blah-blah-blah']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'blah-blah-blah', url: 'url-of-git-repo']]])
script {
if (currentBuild.changeSets.size() > 0) {
echo 'Found ' + currentBuild.changeSets.size() + ' change sets'
build 'real-build-job'
}
else {
echo 'Found no change sets'
}
}
}
post {
failure {
echo 'FAILED in stage ScmFetch'
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.