我正在将旧的 Jenkins 构建迁移到新的声明性管道。现在我已经构建并运行了,我需要从 git 获取 JenkinsFile(而不是将其留在 Jenkins 窗口中)。问题是 Jenkins 从 Git 获取文件,但在 pull 文件后在错误的位置查找它。这是配置:
这是我在 Jenkins 日志中收到的消息:
Checking out git https://github.com/xxx/xxx_dev.git to read Jenkinsfile
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/xxx/xxx_dev.git # timeout=10
Fetching upstream changes from https://github.com/xxx/xxx_dev.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials xxx Build
> git fetch --tags --progress https://github.com/xxx/xxx_dev.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 43bd167e0e222fb517a8deb5ce6c6c6ba3619153 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 43bd167e0e222fb517a8deb5ce6c6c6ba3619153
> git rev-list 82e6fdcce2587aa6368d63449ac57c9f02a1f835 # timeout=10
ERROR: /u03/jenkins/jobs/xxx/jobs/Build_Main/jobs/vs2015/workspace@script/Jenkinsfile not found
Finished: FAILURE
构建代理似乎正在主 Jenkins 服务器计算机上的某个位置查找 Jenkins 文件。构建机器是 Windows 机器,因此/u03/jenkins/jobs/xxx/jobs/Build_Main/jobs/vs2015/workspace@script/Jenkinsfile 没有任何意义。有谁知道这是怎么回事吗?
谢谢!
最佳答案
由于您在问题中提到的文件名,我认为您命名错误。
该脚本已在项目的根目录中搜索,并且应名为 Jenkinsfile
而不是 JenkinsFile
。
因此请正确命名该文件并将其移至存储库的根目录中。
关于git - Jenkins 在从 SCM 中查找 JenkinsFile 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45178352/