Я управляю эфемерным модулем Дженкинса в моем проекте openshift. Это мой Дженкинсфайл.
pipeline{
agent {
label 'maven'
}
stages{
stage('Checkout from GitLab'){
steps{
echo "GitLab Check out..."
git branch: "<git-branch-here>",
credentialsId: "<gitlab-credentials-here>",
url: "git@gitlab.hostname.blah:projects/spring-boot-helloworld.git"
}
}
stage('Invoking mvn commands'){
steps{
sh "mvn clean install package"
}
}
stage('Create the Image Builder'){
when{
expression{
openshift.withCluster(){
return !openshift.selector("bc", "new-pipeline").exists()
}
}
}
steps{
script{
openshift.withCluster(){
openshift.withProject(){
echo "Creating a new build."
def created = openshift.newBuild("--name=new-pipeline", "--image-stream=springboot-maven3", "--binary")
}
}
}
}
}
}
}
Я получаю ошибку ...
[start-build:buildconfig/new-pipeline] [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/opt/app-root/src). Please verify you invoked Maven from the correct directory. -> [Help 1]
[start-build:buildconfig/new-pipeline] [ERROR]
[start-build:buildconfig/new-pipeline] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[start-build:buildconfig/new-pipeline] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[start-build:buildconfig/new-pipeline] [ERROR]
[start-build:buildconfig/new-pipeline] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[start-build:buildconfig/new-pipeline] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
[start-build:buildconfig/new-pipeline] error: build error: non-zero (13) exit code from codecentric/springboot-maven3-centos@sha256:91ecee201c42cfde8616dfe7b5c77c4f6100f95f50c6e8ffe16a78c99dde59bf
[start-build:buildconfig/new-pipeline]
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Create DEV)
Stage 'Create DEV' skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Error running start-build on at least one item: [buildconfig/new-pipeline];
{reference={}, err=Uploading file "target/hello-world-service-1.0.0.jar" as binary input for the build ...
error: the build pipelineproject/new-pipeline-1 status is "Failed", verb=start-build, cmd=oc --server=https://172.30.0.1:443 --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --namespace=pipelineproject --token=XXXXX start-build buildconfig/new-pipeline --from-file=./target/hello-world-service-1.0.0.jar --wait --follow -o=name , out=build/new-pipeline-1
Receiving source from STDIN as file hello-world-service-1.0.0.jar
---> Restore build artifacts
---> Installing application source
---> Building Spring Boot application from source
--> # MVN_ARGS =
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.095 s
[INFO] Finished at: 2018-11-06T04:19:02+00:00
[INFO] Final Memory: 13M/360M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/opt/app-root/src). 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
error: build error: non-zero (13) exit code from codecentric/springboot-maven3-centos@sha256:91ecee201c42cfde8616dfe7b5c77c4f6100f95f50c6e8ffe16a78c99dde59bf, status=1}
Я вошел в капсулу Дженкинса через: oc rsh jenkins-1-vwt2g
И попытался найти каталог / opt / app-root / src
sh-4.2$ pwd
/opt
sh-4.2$ cd app-root
sh: cd: app-root: No such file or directory
Я также искал hello-world-service-1.0.0.jar
sh-4.2$ cd /
sh-4.2$ find . -name hello*.jar
Но я не нашел ни одного.
Я искал каталог, в который загружается исходный код git.
sh-4.2$ pwd
/var/lib/jenkins/jobs/pipelineproject/jobs/pipelineproject-hello-world-pipeline-ver2/workspace
sh-4.2$ ls -al
total 36
drwxr-sr-x. 4 default 1000260000 191 Nov 6 02:43 .
drwxr-sr-x. 7 default 1000260000 191 Nov 6 04:12 ..
drwxr-sr-x. 8 default 1000260000 162 Nov 6 02:43 .git
-rw-r--r--. 1 default 1000260000 381 Nov 6 02:43 hello-world-pipeline-ver2.yaml
-rw-r--r--. 1 default 1000260000 5934 Nov 6 02:43 Jenkinsfile
-rw-r--r--. 1 default 1000260000 10635 Nov 6 02:43 pom.xml
drwxr-sr-x. 3 default 1000260000 18 Nov 6 02:43 src
В сообщении об ошибке упоминается / opt / app-root / src, но исходная папка, в которую был загружен исходный файл git, является / var / lib / jenkins / jobs / pipelineproject / jobs / pipelineproject-hello-world-pipeline-ver2 / рабочее место
Как мне согласовать это в моем конвейере jenkins внутри openshift, чтобы при запуске startBuild он знал, где находится настоящий файл jar (я даже не знаю, где maven сгенерировал файл jar - после этой команды mvn clean install package ).
Кстати, в команде mvn, а именно в команде установки, это связанный журнал
[INFO] Installing /tmp/workspace/pipelineproject/pipelineproject-hello-world-pipeline-ver2/target/hello-world-service-1.0.0.jar to /home/jenkins/.m2/repository/blah/blah/blah/spring-boot/hello-world-service/1.0.0/hello-world-service-1.0.0.jar
У меня есть каталог / home, но он ничего не содержит (т. Е. Нет каталога jenkins / ...).
openshift v3.9.43
kubernetes v1.9.1+a0ce1bc657