【发布时间】:2019-10-20 10:44:12
【问题描述】:
为了总结这个问题,我有一个名为 Repo_A 的 git 存储库。
Repo_A 包含:
Repo_A:
---> release-pipeline.gdsl
---> src/
---> pom.xml
release-pipeline.gdsl 内容:
node(params.node) {
stage('Build Source Code') {
sh 'pwd'
sh 'ls -l'
sh 'mvn clean compile package'
}
}
stage的输出如下(Jenkins项目名称Repo_A_CI_Project):
Started by user MyUser
Obtained release-pipeline.gdsl from git git@github.com:Repo_A.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on myServer in /home/MyHome/jenkins_agent/workspace/Repo_A_CI_Project
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build Source Code)
[Pipeline] sh
+ pwd
/home/MyHome/jenkins_agent/workspace/Repo_A_CI_Project
[Pipeline] sh
+ ls -l
total 0
[Pipeline] sh
+ mvn clean compile package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.735 s
[INFO] Finished at: 2019-10-20T09:26:34+00:00
[INFO] Final Memory: 25M/1963M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/MyHome/jenkins_agent/workspace/Repo_A_CI_Project). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
ERROR: script returned exit code 1
Finished: FAILURE
这里的问题是 Jenkins Pipeline 不会克隆整个 Repo_A 存储库内容。它只获取 gdsl 文件release-pipeline.gdsl。
工作是管道类型,我已经为这个项目设置了正确的配置,git repo 应该拉什么。
以前它可以正常工作并拉取整个 repo 并考虑 repo 根目录上的执行位置以开始执行阶段的命令。
从日志中可以看出,我使用ls -l 来查看内容,结果显示为0。
[Pipeline] sh
+ ls -l
total 0
[Pipeline]
我希望看到这样的情况
[Pipeline] sh
+ ls
release-pipeline.gdsl src/ pom.xml
[Pipeline]
在 Jenkins 日志中,我看到的唯一内容就是这条简单的消息。
org.jenkinsci.plugins.githubautostatus.GithubNotificationConfig log
INFO: Could not find commit sha - status will not be provided for this build
我正在使用这种方法,因为它很容易拉取 Jenkins 构建文件 (release-pipeline.gdsl) 以及 repo 的其他内容直接构建而无需额外步骤。
感谢您的帮助。
【问题讨论】:
标签: git jenkins jenkins-pipeline