基本Jenkins管道失败

时间:2016-10-27 12:45:51

标签: jenkins openshift jenkins-pipeline

我在Openshift上运行了Jenkins 1.6。我正在尝试构建一个简单的Jenkins管道,它是从Git存储库构建的:

node {
  git url: 'https://github.com/fmarchioni/kitchensink-example.git'
  def mvnHome = tool 'M3'
  sh "${mvnHome}/bin/mvn clean install"
}

当我尝试构建管道时,它失败并显示不明确的消息:

[Pipeline] node
Running on master in /var/lib/jenkins/jobs/pipeline/workspace
[Pipeline] {
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/fmarchioni/kitchensink-example.git # timeout=10
Fetching upstream changes from https://github.com/fmarchioni/kitchensink-example.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://github.com/fmarchioni/kitchensink-example.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 90df980f2c86f9a59d872bc8650ecfd0800c51bd (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 90df980f2c86f9a59d872bc8650ecfd0800c51bd # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master 90df980f2c86f9a59d872bc8650ecfd0800c51bd
First time build. Skipping changelog.
[Pipeline] tool
[Pipeline] sh
[workspace] Running shell script
+ /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/M3/bin/mvn clean install
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -1
Finished: FAILURE

你知道可能出现什么问题吗? 感谢

2 个答案:

答案 0 :(得分:1)

我怀疑特定的shell脚本mvn clean install是错误的。如果可以,请尝试通过SSH连接到盒式磁带并直接尝试该Mavin命令。您可以添加调试选项(来自https://books.sonatype.com/mvnref-book/reference/running-sect-options.html)并希望看到一些更有用的输出!

答案 1 :(得分:0)

尝试使用withMaven步骤括起命令。这将允许maven工具版本和JDK的规范,以及其他配置选项。

  withMaven(jdk: '<JDK name>', maven: '<maven name>') {
  sh 'mvn clean install'
  }

它还将记录build.log中的配置:

[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] use JDK installation <JDK name>
[withMaven] use Maven installation '<maven name>'
[Pipeline] sh
[workspace] Running shell script

您可能希望查看使用Pipeline Syntax链接。它可以生成可用于单个步骤的片段。它将显示withMaven步骤可用的选项。

enter image description here