【发布时间】:2019-03-13 22:38:02
【问题描述】:
我有一个带有分支参数的 Jenkins 作业,设置为每 5 分钟轮询一次 SCM,并从 SCM 运行管道脚本:
脚本所做的第一件事是删除之前的工作区并获取源代码的新副本:
#!/usr/bin/env groovy
node {
try {
stage('Get Source') {
// Clear the workspace
deleteDir()
// Get the source code
checkout scm
}
// Stages for building and running unit tests...
}
}
根据 Git 轮询日志,它每 5 分钟检查一次存储库,但没有发现任何更改:
Started on Mar 13, 2019 4:29:34 PM
Using strategy: Default
[poll] Last Built Revision: Revision 47251333f2d6c740275f24dd667255e66f7b5665 (refs/remotes/origin/master)
using credential **********
> git --version # timeout=10
using GIT_SSH to set credentials Jenkins SSH Authentication Key
> git ls-remote -h git@bitbucket.org:myuser/myrepo.git # timeout=10
Found 1 remote heads on git@bitbucket.org:myuser/myrepo.git
Using strategy: Default
[poll] Last Built Revision: Revision 47251333f2d6c740275f24dd667255e66f7b5665 (refs/remotes/origin/master)
using credential **********
> git --version # timeout=10
using GIT_SSH to set credentials Jenkins SSH Authentication Key
> git ls-remote -h git@bitbucket.org:myuser/myrepo.git # timeout=10
Found 1 remote heads on git@bitbucket.org:myuser/myrepo.git
Done. Took 1.8 sec
No changes
但是,在 47251333f2d6c740275f24dd667255e66f7b5665 之后还有几个额外的提交已被推送到远程 master 分支。
我读到here,在 SCM 轮询开始工作之前,该作业必须手动运行一次,但我已经手动运行了几次。我做错了什么?
【问题讨论】:
-
对不起,如果这对您没有帮助,但是:您为什么使用轮询?是强制性的吗?你听说过 webhook 吗?这是一种更有效的当前策略。
-
我的 Jenkins 服务器在专用网络上,所以我认为来自 Bitbucket 的 webhook 不会起作用。
标签: git jenkins jenkins-pipeline