无法建立内置的詹金斯管道

时间:2018-06-25 17:06:23

标签: jenkins jenkins-pipeline

我正在尝试构建我的第一个管道,并以内置的Git管道为例:

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
      if (isUnix()) {
         sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
      } else {
         bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/)
      }
   }
   stage('Results') {
      junit '**/target/surefire-reports/TEST-*.xml'
      archive 'target/*.jar'
   }
}

不幸的是,它失败并显示以下错误:

Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /home/user01/.jenkins/workspace/mypipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Preparation)
[Pipeline] tool
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] isUnix
[Pipeline] sh
[mypipeline] Running shell script
+ /home/user01/apache/apache-maven-3.5.3/bin/mvn -Dmaven.test.failure.ignore clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.092 s
[INFO] Finished at: 2018-06-25T19:13:53+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/user01/.jenkins/workspace/mypipeline). 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
ERROR: script returned exit code 1

我遵循的步骤是Jenkins Wiki中描述的步骤,即:

  • 安装管道插件
  • 在全局配置中定义Maven(M3)工具
  • 配置JDK路径
  • 配置Git路径

如果我尝试这样做:

ls /home/user01/.jenkins/workspace/mypipeline

它确实为空,因此准备阶段不会在本地克隆项目。为什么呢我想念什么?谢谢!!!

0 个答案:

没有答案