[Jhipster CI-CD jenkins管道的npm安装错误

问题描述 投票:0回答:1

我正在尝试使用jhipster ci-cd创建Jenkins管道。

但是当我在Jenkins服务器中运行jenkins管道时,出现以下错误。

注意:我的jenkins服务器是在Ubuntu EC2实例上运行的Jenkins实例[NOT DOCKERISED JENKINS]

附加Jenkins文件以供参考。

Jenkinsfile.txt

./mvnw -ntp com.github.eirslett:frontend-maven-plugin:npm
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.jhip.poc:jhipprojectmono >--------------------
[INFO] Building Jhipprojectmono 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- frontend-maven-plugin:1.8.0:npm (default-cli) @ jhipprojectmono ---
[INFO] Running 'npm install' in /var/lib/jenkins/workspace/jhipprojectmono
[INFO] npm ERR! correctMkdir failed to make directory /.npm/_locks
[INFO] npm ERR! code EACCES
[INFO] npm ERR! syscall mkdir
[INFO] npm ERR! path /.npm
[INFO] npm ERR! errno -13
[INFO] npm ERR!
[INFO] npm ERR! Your cache folder contains root-owned files, due to a bug in
[INFO] npm ERR! previous versions of npm which has since been addressed.
[INFO] npm ERR!
[INFO] npm ERR! To permanently fix this problem, please run:
[INFO] npm ERR! sudo chown -R 111:115 "/.npm"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.723 s
[INFO] Finished at: 2020-02-19T14:33:40Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.8.0:npm (default-cli) on project jhipprojectmono: Failed to run task: 'npm install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 243 (Exit value: 243) -> [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/MojoFailureException

---------- Jenkins文件--------

#!/usr/bin/env groovy

node {
    stage('checkout') {
        checkout scm
    }

    //gitlabCommitStatus('build') {
    gitlabCommitStatus {

        docker.image('jhipster/jhipster:v6.5.1').inside('-e MAVEN_OPTS="-Duser.home=./"') {
        //docker.image('openjdk:8').inside('-u jhipster -e MAVEN_OPTS="-Duser.home=./"') {

            stage('path') {
                sh "pwd"
                sh "ls -ltr"
            }
            stage('check java') {
                sh "java -version"
            }

            stage('clean') {
                sh "chmod +x mvnw"
                sh "./mvnw -ntp clean"
            }
            stage('nohttp') {
                sh "./mvnw -ntp checkstyle:check"
            }

            stage('install tools') {
                sh "./mvnw -ntp com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v12.13.0 -DnpmVersion=6.13.0"
            }

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

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

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

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

        def dockerImage
        stage('publish docker') {
            // A pre-requisite to this step is to setup authentication to the docker registry
            // https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#authentication-methods
            sh "./mvnw -ntp jib:build"
        }
    }
}
jenkins jenkins-pipeline jhipster npm-install
1个回答
0
投票

也许您可以尝试添加

    environment {
        HOME = '.'
    }

© www.soinside.com 2019 - 2024. All rights reserved.