我遇到一个奇怪的行为,我今天做的第一个尝试用詹金斯管道,并试图使用运行在作业内的实际面积的管道提供的样品简单管道。詹金斯管道:不签代码
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/jglick/simple-maven-project-with-tests.git'
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'M3'
}
stage('Build') {
// Run the maven build
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
}
stage('Results') {
junit '**/target/surefire-reports/TEST-*.xml'
archive 'target/*.jar'
}
}
奇怪的是:当我运行的作业,它正确运行准备阶段,然后去建立和失败的说法是没有的pom.xml来执行,而是寻找到所有的执行日志没有提到git操作发生。我查看了作业文件夹,并且没有任何关于我试图在那里克隆的git存储库。
[Pipeline] node
Running on master in /Users/user/.jenkins/workspace/Test-Pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Preparation)
[Pipeline] tool
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
[Test-Pipeline] Running shell script
+ /opt/software/apache-maven-3.3.9/bin/mvn -Dmaven.test.failure.ignore clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.057 s
[INFO] Finished at: 2017-03-08T22:54:41-05:00
[INFO] Final Memory: 7M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/user/.jenkins/workspace/Test-Pipeline). 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
我试图添加url属性,但也没有工作。根据配置管道本身应该包括混帐,所以我猜我在这里做错了什么。
我的配置: 詹金斯2.32.3与管道2.5
任何建议表示赞赏。
看起来对我来说是正确的,不确定是否粘贴了整个脚本,如果没有,p确保你没有在某处重新定义'git'。例如。 'def git = ...'或类似的。 –
事实上,git工具似乎没有找到,我只是测试了这个确切的示例代码,并且我有'克隆远程Git存储库'输出。另外,我注意到在你的日志一件奇怪的事情:你的工作说,这是在路径运行'/用户/用户/ .jenkins /工作区/测试-Pipeline'而你MVN工具位于'/选择/软件/阿帕奇-maven-3.3.9/bin/mvn' ...你是否使用了一个奇怪的Windows/Unix混合体,就像Windows安装的文件夹一样? – Pom12
感谢@ Pom12 - 我使用的是Mac,但我会检讨我的配置,我的混帐,因为我没有与正常詹金斯建设(非管道)进行测试,因为它的一个全新安装。 – Thiago