2017-10-17 15 views
0

私はいくつかの投稿を見てきましたが、私の問題の解決策を見つけることができませんでした。 Jenkinsでは、私はパイプラインをmavenプロジェクトで設定しています。テストをローカルで問題なく実行でき、テスト結果がターゲットフォルダに生成されます。問題は、ジンキンズのフォルダ構造が異なるため、テストではJenkins Build Processをパスしないということです。Jenkins Maven Build - >変更ディレクトリ

[ERROR] Command was /bin/sh -c cd /var/lib/jenkins/jobs/test/workspace 

パスはジェンキンスがlibの下にそこにはジェンキンスフォルダをされ実行されていないサーバーで

/var/lib/docker/volumes/jenkins-data_var_lib_jenkins`/_data/jobs/test/workspace# 

のようなものでなければなりません:エラーメッセージでは、私はそれが正しいパスを使用していないことを確認しますフォルダ。私は検索を行い、jenkinsフォルダがlib/docker/volumes以下であることを発見しました。しかし何とかコンソールのビルドプロセス中に

Running on master in /var/lib/jenkins/jobs/test/workspace 

この変更はどこで行えますか? 何か助けていただければ幸いです。私は

#!/usr/bin/env groovy 

node { 

    stage('checkout') { 
     checkout scm 
    } 

    stage('check java') { 
     sh "java -version" 
    } 

    stage('clean') { 
     sh "chmod +x mvnw" 
     sh "./mvnw clean" 
    } 

    stage('install tools') { 
     sh "./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v6.11.3 -DyarnVersion=v1.1.0" 
    } 

    stage('yarn install') { 
     sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn" 
    } 


    stage('backend tests') { 
     try { 
      sh "./mvnw test" 
     } catch(err) { 
      throw err 
     } finally { 
      junit '**/target/surefire-reports/TEST-*.xml' 
     } 
    } 

    stage('frontend tests') { 
     try { 
      sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn -Dfrontend.yarn.arguments=test" 
     } catch(err) { 
      throw err 
     } finally { 
      junit '** /target/test-results/karma/TESTS-*.xml' 
     } 
    } 

    stage('packaging') { 
     sh "./mvnw package -Pprod -DskipTests" 
     archiveArtifacts artifacts: '**/target/*.war', fingerprint: true 
    } 

} 

私は上記の言ったように、ビルドプロセス中にエラーレポートが(以下され、何のジェンキンスフォルダがの/ var/libの下にはありません:私のJenkinsfileは、私が使用しているフレームワークから生成され、このようになりました二つの異なるワークスペースに問題があると思いますが、どのように私はこれを適応させることができる?

 Started by an SCM change 
     Obtained Jenkinsfile from git https://github.com/....git 
     [Pipeline] node 
     Running on master in /var/lib/jenkins/jobs/test/workspace 
     [Pipeline] { 
     [Pipeline] stage 
     [Pipeline] { (checkout) 
     [Pipeline] checkout 
     > git rev-parse --is-inside-work-tree # timeout=10 
     Fetching changes from the remote Git repository 
     > git config remote.origin.url https://github.com/.....git # timeout=10 
     Fetching upstream changes from https://github.com/.......git 
     > git --version # timeout=10 
     using GIT_ASKPASS to set credentials 
     > git fetch --tags --progress https://github.com/........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 ..... 
    (refs/remotes/origin/master) 
     > git config core.sparsecheckout # timeout=10 
     > git checkout -f ........ 
     Commit message: "Merge branch 'master' of https://github.com/......" 
     > git rev-list ....... # timeout=10 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] stage 
     [Pipeline] { (check java) 
     [Pipeline] sh 
     [workspace] Running shell script 
     + java -version 
     openjdk version "1.8.0_112" 
     OpenJDK Runtime Environment (build 1.8.0_112-b15) 
     OpenJDK 64-Bit Server VM (build 25.112-b15, mixed mode) 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] stage 
     [Pipeline] { (clean) 
     [Pipeline] sh 
     [workspace] Running shell script 
     + chmod +x mvnw 
     [Pipeline] sh 
     [workspace] Running shell script 
     + ./mvnw clean 
     [INFO] Scanning for projects... 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Building Test 0.0.1-SNAPSHOT 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] 
     [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ test--- 
     [INFO] Deleting /var/lib/jenkins/jobs/test/workspace/target 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] BUILD SUCCESS 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Total time: 1.181 s 
     [INFO] Finished at: 2017-10-18T11:32:15Z 
     [INFO] Final Memory: 12M/106M 
     [INFO] ------------------------------------------------------------------------ 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] stage 
     [Pipeline] { (install tools) 
     [Pipeline] sh 
     [workspace] Running shell script 
     + ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v6.11.3 -DyarnVersion=v1.1.0 
     [INFO] Scanning for projects... 
     [INFO] 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Building Test 0.0.1-SNAPSHOT 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] 
     [INFO] --- frontend-maven-plugin:1.6:install-node-and-yarn (default-cli) @ test--- 
     [INFO] Node v6.11.3 is already installed. 
     [INFO] Yarn 1.1.0 is already installed. 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] BUILD SUCCESS 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Total time: 3.126 s 
     [INFO] Finished at: 2017-10-18T11:32:20Z 
     [INFO] Final Memory: 14M/106M 
     [INFO] ------------------------------------------------------------------------ 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] stage 
     [Pipeline] { (yarn install) 
     [Pipeline] sh 
     [workspace] Running shell script 
     + ./mvnw com.github.eirslett:frontend-maven-plugin:yarn 
     [INFO] Scanning for projects... 
------------------------------------------------------------------------ 
     [INFO] Building Test 0.0.1-SNAPSHOT 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] 
     [INFO] --- frontend-maven-plugin:1.6:yarn (default-cli) @ test--- 
     [INFO] Running 'yarn ' in /var/lib/jenkins/jobs/test/workspace 
     [INFO] yarn install v1.1.0 
     [INFO] [1/5] Validating package.json... 
     [INFO] [2/5] Resolving packages... 
     [INFO] success Already up-to-date. 
     [INFO] Done in 2.39s. 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] BUILD SUCCESS 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Total time: 4.316 s 
     [INFO] Finished at: 2017-10-18T11:32:27Z 
     [INFO] Final Memory: 12M/106M 
     [INFO] ------------------------------------------------------------------------ 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] stage 
     [Pipeline] { (backend tests) 
     [Pipeline] sh 
     [workspace] Running shell script 
     + ./mvnw test 
     [INFO] Scanning for projects... 
     ------------------------------------------------------------------------ 
     [INFO] Building Test 0.0.1-SNAPSHOT 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] 
     [INFO] --- maven-resources-plugin:3.0.1:copy-resources (default-resources) @ test--- 
     [INFO] Using 'UTF-8' encoding to copy filtered resources. 
     [INFO] Copying 19 resources 
     [INFO] Copying 11 resources 
     [INFO] 
     [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ test--- 
     [INFO] Using 'UTF-8' encoding to copy filtered resources. 
     [INFO] Copying 19 resources 
     [INFO] Copying 11 resources 
     [INFO] 
     [INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ test--- 
     [INFO] 
     [INFO] --- maven-resources-plugin:3.0.1:copy-resources (docker-resources) @ test--- 
     [INFO] Using 'UTF-8' encoding to copy filtered resources. 
     [INFO] Copying 2 resources 
     [INFO] 
     [INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (pre-unit-tests) @ test--- 
     [INFO] argLine set to -javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/var/lib/jenkins/jobs/test/workspace/target/test-results/coverage/jacoco/jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx256m 
     [INFO] 
     [INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ test--- 
     [INFO] Changes detected - recompiling the module! 
     [INFO] Compiling 94 source files to /var/lib/jenkins/jobs/test/workspace/target/classes 
     [INFO] 
     [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ test--- 
     [INFO] Using 'UTF-8' encoding to copy filtered resources. 
     [INFO] Copying 4 resources 
     [INFO] 
     [INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ test--- 
     [INFO] Changes detected - recompiling the module! 
     [INFO] Compiling 22 source files to /var/lib/jenkins/jobs/test/workspace/target/test-classes 
     [INFO] 
     [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ test--- 
     [INFO] Surefire report directory: /var/lib/jenkins/jobs/test/workspace/target/surefire-reports 

     ------------------------------------------------------- 
     T E S T S 
     ------------------------------------------------------- 
     Error: Invalid or corrupt jarfile /var/lib/jenkins/jobs/test/workspace/target/surefire/surefirebooter78063794178.....jar 

     Results : 

     Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

     [INFO] ------------------------------------------------------------------------ 
     [INFO] BUILD FAILURE 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Total time: 13.856 s 
     [INFO] Finished at: 2017-10-18T11:32:43Z 
     [INFO] Final Memory: 49M/334M 
     [INFO] ------------------------------------------------------------------------ 
     [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project test: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called? 
     [ERROR] Command was /bin/sh -c cd /var/lib/jenkins/jobs/test/workspace && /usr/lib/jvm/java-8-openjdk/jre/bin/java -javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/var/lib/jenkins/jobs/test/workspace/target/test-results/coverage/jacoco/jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx256m -jar /var/lib/jenkins/jobs/test/workspace/target/surefire/surefirebooter7806379417818082153.jar /var/lib/jenkins/jobs/test/workspace/target/surefire/surefire6244578096780428228tmp /var/lib/jenkins/jobs/test/workspace/target/surefire/surefire_09182258098509539166tmp 
     [ERROR] -> [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/PluginExecutionException 
     [Pipeline] junit 
     Recording test results 
     [Pipeline] } 
     [Pipeline] // stage 
     [Pipeline] } 
     [Pipeline] // node 
     [Pipeline] End of Pipeline 
     ERROR: No test report files were found. Configuration error? 
     Finished: FAILURE 
+0

もしあなたがJenkinsfileを使っていたら、それを共有できますか? – arifCee

+0

私は自分の質問を編集し、私のjenkinsfileを共有しました。どんな助けも大歓迎です。 – curlie

答えて

0

あなたの仕事を見ることなく伝えるのは難しいが、あなたはおそらく、あなたのワークスペースの上部を取得するために$ワークスペース変数を参照することができます。

+0

この質問は申し訳ありませんが、この参照はどこで作成する必要がありますか?jenkinsファイルも共有しました。私はそこに変更を加えなければならないのですか? – curlie

+0

ファイルにハードコードされたパスを使用している場合は、$ WORKSPACE/[file]を使用します。 $ WORKSPACEは、作業領域の最上位レベルを指します。絶対パスを参照しているJenkinsfileでは私は見えません。ビルドスクリプトでそのようなことをしていますか?ドッカーを使用している場合、ドッカーのワークスペースは、エージェントマシンに表示されているものと異なる場合があります。/bin/sh -c cd/var/lib/jenkins/jobs/test/workspace "? –

+0

テストをビルドしようとしているときにジェンキンのエラーレポートから来ています。問題は、jenkinsが動作しているVM内のjenkinsフォルダを検索すると、上記のようなパスはありません。VM内のjenkinsフォルダは、ワークスペースとは別のパスを持っています。私はこれを解決する方法を知りません、変更を行う場所を尊重します。 – curlie