我有一个带有前端项目模块的maven项目,我用eirslett打包:frontend-maven-plugin。它在本地工作正常但在gitlab.com上构建失败。
我用这个.gitlab-ci.yml:
启动构建image: maven:3.3.9-jdk-8-onbuild
build:
script: "mvn clean install -B -X"
这个pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.nev.oms</groupId>
<artifactId>oms-frontend</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>fr.nev.oms</groupId>
<artifactId>myproject</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<!--<configuration>-->
<nodeVersion>v4.4.7</nodeVersion>
<npmVersion>3.10.5</npmVersion>
<!--</configuration>-->
<environmentVariables>
<NODE_ENV>production</NODE_ENV>
<API_URL></API_URL>
<APP_VERSION></APP_VERSION>
</environmentVariables>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
在gitlab.com上,我有这样的痕迹:
[DEBUG] Configuring mojo com.github.eirslett:frontend-maven-plugin:1.3:install-node-and-npm from plugin realm ClassRealm[plugin>com.github.eirslett:frontend-maven-plugin:1.3, parent: sun.misc.Launcher$AppClassLoader@677327b6]
[DEBUG] Configuring mojo 'com.github.eirslett:frontend-maven-plugin:1.3:install-node-and-npm' with basic configurator -->
[DEBUG] (f) environmentVariables = {API_URL=null, APP_VERSION=null, NODE_ENV=production}
[DEBUG] (f) nodeDownloadRoot = https://nodejs.org/dist/
[DEBUG] (f) nodeVersion = v4.4.7
[DEBUG] (f) npmDownloadRoot = http://registry.npmjs.org/npm/-/
[DEBUG] (f) npmVersion = 3.10.5
[DEBUG] (f) project = MavenProject: fr.nev.oms:oms-frontend:1.0.0-SNAPSHOT @ /builds/nieven/on-my-shelves/oms-frontend/pom.xml
[DEBUG] (f) repositorySystemSession = org.eclipse.aether.DefaultRepositorySystemSession@a10c1b5
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@644abb8f
[DEBUG] (f) skip = false
[DEBUG] (f) skipTests = false
[DEBUG] (f) workingDirectory = /builds/nieven/on-my-shelves/oms-frontend
[DEBUG] (f) execution = com.github.eirslett:frontend-maven-plugin:1.3:install-node-and-npm {execution: install node and npm}
[DEBUG] -- end configuration --
[INFO] Installing node version v4.4.7
[DEBUG] Creating install directory /builds/nieven/on-my-shelves/oms-frontend/node
[DEBUG] Creating temporary directory /builds/nieven/on-my-shelves/oms-frontend/node/tmp
[INFO] Downloading https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.gz to /root/.m2/repository/com/github/eirslett/node/4.4.7/node-4.4.7-linux-x64.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /root/.m2/repository/com/github/eirslett/node/4.4.7/node-4.4.7-linux-x64.tar.gz into /builds/nieven/on-my-shelves/oms-frontend/node/tmp
[INFO] Copying node binary from /builds/nieven/on-my-shelves/oms-frontend/node/tmp/node-v4.4.7-linux-x64/bin/node to /builds/nieven/on-my-shelves/oms-frontend/node/node
[DEBUG] Deleting temporary directory /builds/nieven/on-my-shelves/oms-frontend/node/tmp
[INFO] Installed node locally.
[INFO] Installing npm version 3.10.5
[INFO] Downloading http://registry.npmjs.org/npm/-/npm-3.10.5.tgz to /root/.m2/repository/com/github/eirslett/npm/3.10.5/npm-3.10.5.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /root/.m2/repository/com/github/eirslett/npm/3.10.5/npm-3.10.5.tar.gz into /builds/nieven/on-my-shelves/oms-frontend/node/node_modules
[INFO] Installed npm locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.3:npm (npm install) @ oms-frontend ---
[DEBUG] Configuring mojo com.github.eirslett:frontend-maven-plugin:1.3:npm from plugin realm ClassRealm[plugin>com.github.eirslett:frontend-maven-plugin:1.3, parent: sun.misc.Launcher$AppClassLoader@677327b6]
[DEBUG] Configuring mojo 'com.github.eirslett:frontend-maven-plugin:1.3:npm' with basic configurator -->
[DEBUG] (f) arguments = install
[DEBUG] (f) environmentVariables = {API_URL=null, APP_VERSION=null, NODE_ENV=production}
[DEBUG] (f) npmInheritsProxyConfigFromMaven = true
[DEBUG] (f) project = MavenProject: fr.nev.oms:oms-frontend:1.0.0-SNAPSHOT @ /builds/nieven/on-my-shelves/oms-frontend/pom.xml
[DEBUG] (f) repositorySystemSession = org.eclipse.aether.DefaultRepositorySystemSession@a10c1b5
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@644abb8f
[DEBUG] (f) skip = false
[DEBUG] (f) skipTests = false
[DEBUG] (f) workingDirectory = /builds/nieven/on-my-shelves/oms-frontend
[DEBUG] (f) execution = com.github.eirslett:frontend-maven-plugin:1.3:npm {execution: npm install}
[DEBUG] -- end configuration --
[INFO] Running 'npm install' in /builds/nieven/on-my-shelves/oms-frontend
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myproject .......................................... SUCCESS [ 3.446 s]
[INFO] oms-frontend ....................................... FAILURE [ 8.628 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.254 s
[INFO] Finished at: 2016-12-11T12:14:19+00:00
[INFO] Final Memory: 14M/197M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.3:npm (npm install) on project oms-frontend: Execution npm install of goal com.github.eirslett:frontend-maven-plugin:1.3:npm failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.3:npm (npm install) on project oms-frontend: Execution npm install of goal com.github.eirslett:frontend-maven-plugin:1.3:npm failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution npm install of goal com.github.eirslett:frontend-maven-plugin:1.3:npm failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.NullPointerException
at java.lang.ProcessEnvironment.validateValue(ProcessEnvironment.java:120)
at java.lang.ProcessEnvironment.access$400(ProcessEnvironment.java:61)
at java.lang.ProcessEnvironment$Value.valueOf(ProcessEnvironment.java:203)
at java.lang.ProcessEnvironment$StringEnvironment.put(ProcessEnvironment.java:243)
at java.lang.ProcessEnvironment$StringEnvironment.put(ProcessEnvironment.java:221)
at java.util.AbstractMap.putAll(AbstractMap.java:281)
at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.createProcessBuilder(ProcessExecutor.java:103)
at com.github.eirslett.maven.plugins.frontend.lib.ProcessExecutor.<init>(ProcessExecutor.java:37)
at com.github.eirslett.maven.plugins.frontend.lib.NodeExecutor.<init>(NodeExecutor.java:20)
at com.github.eirslett.maven.plugins.frontend.lib.NodeTaskExecutor.execute(NodeTaskExecutor.java:58)
at com.github.eirslett.maven.plugins.frontend.mojo.NpmMojo.execute(NpmMojo.java:62)
at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:89)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
[ERROR]
你对这个问题的解决方案有什么想法吗?
答案 0 :(得分:0)
我有类似的问题(构建传递在win中并且在Linux上使用此NullPointer失败)并将frontend-maven-plugin
更新为最新版本(在我的情况下为1.4)帮助。
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>