git - Jenkins 在从 SCM 中查找 JenkinsFile 时遇到问题

标签 git github jenkins jenkins-pipeline

我正在将旧的 Jenkins 构建迁移到新的声明性管道。现在我已经构建并运行了,我需要从 git 获取 JenkinsFile(而不是将其留在 Jenkins 窗口中)。问题是 Jenkins 从 Git 获取文件,但在 pull 文件后在错误的位置查找它。这是配置:

enter image description here

这是我在 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/

相关文章:

xcode - RPC 失败; curl 56 SSLRead() 返回错误 -9806 MiB/s

codeigniter - 在 github 上 fork CodeIgniter

c++ - 用于 C++ 持续集成的 buildbot vs hudson/jenkins

jenkins - 如何更改 cobertura 报告中名称列的值

git - 如何从 git 图形颜色中排除颜色?

git - 将 git .gitignore 规则应用于现有存储库

java - Java中通过Jgit忽略文件或文件夹

Git 钩子(Hook)预提交错误 : "command not found"

github - 如何直接从 Github (raw.github.com) 链接文件

docker - Jenkinsfile管道:从另一个访问一个Docker容器