首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用eirslett在gitlab.com上运行maven build :前端-maven-plugin

用eirslett在gitlab.com上运行maven build :前端-maven-plugin
EN

Stack Overflow用户
提问于 2016-12-11 21:05:16
回答 1查看 1.4K关注 0票数 3

我有一个带有前端项目模块的maven项目,它是我用eirslett打包的: front -maven-plugin。它在本地运行良好,但在gitlab.com上构建失败。

我使用.gitlab-ci.yml启动构建:

代码语言:javascript
复制
image: maven:3.3.9-jdk-8-onbuild

build:
  script: "mvn clean install -B -X"

和这个pom.xml:

代码语言:javascript
复制
<?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上,我有这样的跟踪:

代码语言:javascript
复制
[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] 

你知道这个问题的解决方法吗?

EN

回答 1

Stack Overflow用户

发布于 2017-05-15 21:15:29

我也遇到过类似的问题(构建时传入了win,并且在linux上使用这个NullPointer失败了),并且将frontend-maven-plugin更新到最新版本(在我的例子中是1.4)很有帮助。

代码语言:javascript
复制
<plugin>
  <groupId>com.github.eirslett</groupId>
  <artifactId>frontend-maven-plugin</artifactId>
  <version>1.4</version>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41086494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档