Jenkins pipeline checkout 错误修改
Jenkins pipeline checkout wrong revision
我正在尝试使用 Jenkinsfile 实施新的 Jenkins 管道。
GIT 存储库并没有在每个分支上都有 Jenkinsfile,只是在特定分支下(因为我目前正在为遗留存储库构建 CI 东西)。
Jenkins 管道是使用以下配置创建的:
- 丢弃旧版本(我不想手动清理)
- Bitbucket webhook 触发器(在推送事件时)
- 来自 SCM 的流水线脚本
- Bitbucket 服务器(使用 Bitbucket 服务器插件)
- 身份验证内容
- 要构建的分支:
**
- 脚本路径:
Jenkinsfile
- 轻量级结帐已禁用
webhook 是在我的 Bitbucket 存储库中自动创建的,并且构建被触发得很好(当我使用 Jenkinsfile
在分支上推送修改时)。
但是,Jenkins 不会检查挂钩中发送的提交(来自另一个分支的不同 HASH)。结果,构建崩溃,因为 Jenkinsfiles
在另一个分支上不存在(并且永远不会存在于旧的遗留分支上)。
> git fetch --tags --force --progress -- http://mybitbucket:port/scm/vs/myrepo.git +refs/heads/*:refs/remotes/myrepo/* # timeout=10
Seen branch in repository myrepo/old-branch-a
Seen branch in repository myrepo/old-branch-b
...
Seen 40 remote branches
> git show-ref --tags -d # timeout=10
Checking out Revision 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 (myrepo/old-branch-x)
> git config core.sparsecheckout # timeout=10
> git checkout -f 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 # timeout=10
Commit message: "my commit message"
First time build. Skipping changelog.
Posting build status of INPROGRESS to mybitbucket for commit id [0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76] and ref 'null'
ERROR: /var/jenkins_home/workspace/myrepo@script/Jenkinsfile not found
技术背景:
- Jenkins 2.303.3 运行 在 docker 容器中
- Bitbucket server integration 插件
我不明白为什么选择这个修订版而不是挂钩中发送的修订版。
非常感谢您的帮助!
我一直被误导了。
原来我需要使用 Multibranch pipelines
而不是常规的。它运行良好,并根据需要自动创建 webhook(使用正确的 Scan Multibranch Pipeline Triggers
配置)。
我仍然对常规管道的行为感到沮丧,这对我来说毫无意义,而且似乎没有很好的记录。
我正在尝试使用 Jenkinsfile 实施新的 Jenkins 管道。
GIT 存储库并没有在每个分支上都有 Jenkinsfile,只是在特定分支下(因为我目前正在为遗留存储库构建 CI 东西)。
Jenkins 管道是使用以下配置创建的:
- 丢弃旧版本(我不想手动清理)
- Bitbucket webhook 触发器(在推送事件时)
- 来自 SCM 的流水线脚本
- Bitbucket 服务器(使用 Bitbucket 服务器插件)
- 身份验证内容
- 要构建的分支:
**
- 脚本路径:
Jenkinsfile
- 轻量级结帐已禁用
webhook 是在我的 Bitbucket 存储库中自动创建的,并且构建被触发得很好(当我使用 Jenkinsfile
在分支上推送修改时)。
但是,Jenkins 不会检查挂钩中发送的提交(来自另一个分支的不同 HASH)。结果,构建崩溃,因为 Jenkinsfiles
在另一个分支上不存在(并且永远不会存在于旧的遗留分支上)。
> git fetch --tags --force --progress -- http://mybitbucket:port/scm/vs/myrepo.git +refs/heads/*:refs/remotes/myrepo/* # timeout=10
Seen branch in repository myrepo/old-branch-a
Seen branch in repository myrepo/old-branch-b
...
Seen 40 remote branches
> git show-ref --tags -d # timeout=10
Checking out Revision 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 (myrepo/old-branch-x)
> git config core.sparsecheckout # timeout=10
> git checkout -f 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 # timeout=10
Commit message: "my commit message"
First time build. Skipping changelog.
Posting build status of INPROGRESS to mybitbucket for commit id [0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76] and ref 'null'
ERROR: /var/jenkins_home/workspace/myrepo@script/Jenkinsfile not found
技术背景:
- Jenkins 2.303.3 运行 在 docker 容器中
- Bitbucket server integration 插件
我不明白为什么选择这个修订版而不是挂钩中发送的修订版。
非常感谢您的帮助!
我一直被误导了。
原来我需要使用 Multibranch pipelines
而不是常规的。它运行良好,并根据需要自动创建 webhook(使用正确的 Scan Multibranch Pipeline Triggers
配置)。
我仍然对常规管道的行为感到沮丧,这对我来说毫无意义,而且似乎没有很好的记录。