I have a multi-module maven project using Java 11
, Maven 3.6.3
where one of the modules uses frontend-maven-plugin plugin.
When running locally on macOS, everything works fine, when running with GitLab runner it fails.
Here is the project pom.xml
file in my-project/app-client
folder:
<?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>com.xxx.xxx</groupId>
<artifactId>app-client</artifactId>
<name>app-client</name>
<description>client</description>
<packaging>pom</packaging>
<version>1.2.3</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>11</java.version>
<maven-assembly-plugin.version>2.4</maven-assembly-plugin.version>
<frontend-maven-plugin.version>1.13.4</frontend-maven-plugin.version>
<frontend-maven-plugin.nodeVersion>v12.4.0</frontend-maven-plugin.nodeVersion>
</properties>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<frontBuild>run build</frontBuild>
</properties>
</profile>
<profile>
<id>uat</id>
<properties>
<frontBuild>run build:test</frontBuild>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<frontBuild>run build:prod</frontBuild>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<configuration>
<workingDirectory>client</workingDirectory>
<installDirectory>target</installDirectory>
</configuration>
<executions>
<execution>
<id>install node</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>${frontend-maven-plugin.nodeVersion}</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g npm-install-peers</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>${frontBuild}</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>generate-client-package</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly/webclient_assembly_descr.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is .gitlab-ci.yaml
file:
image: maven:3.6.3-jdk-11
stages:
- build_client
- compile
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .m2/repository/
- node_modules/
before_script:
- apt-get update && apt-get install -y curl
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get install -y nodejs
#- npm install -g @angular/cli@8.3.19 -> add to fix the error: 'ng' command was not found
build_client:
stage: build_client
script:
- cd app-client/client
- npm install
compile:
stage: compile
script:
- cd app-client
- mvn clean install -DskipTests
I limited the GitLab CI just for the failing module. So there are 2 stages, the 1st is OK, but the 2 fails with:
[INFO] Copying node binary from /builds/my-company/my-project/app-client/target/node/tmp/node-v12.4.0-linux-x64/bin/node to /builds/my-company/my-project/app-client/target/node/node
[INFO] Extracting NPM
[INFO] Installed node locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.13.4:npm (npm install) @ app-client ---
[INFO] Running 'npm install -g npm-install-peers' in /builds/my-company/my-project/app-client/client
[INFO] /builds/my-company/my-project/app-client/target/bin/npm-install-peers -> /builds/my-company/my-project/app-client/target/lib/node_modules/npm-install-peers/bin/npm-install-peers.js
[INFO] + npm-install-peers@1.2.2
[INFO] added 466 packages from 897 contributors in 6.431s
[INFO]
[INFO] --- frontend-maven-plugin:1.13.4:npm (npm run build) @ app-client ---
[INFO] Running 'npm run build' in /builds/my-company/my-project/app-client/client
[INFO]
[INFO] > web-plage@0.0.0 build /builds/my-company/my-project/app-client/client
[INFO] > ng build
[INFO]
[INFO] sh: 1: ng: not found
[INFO] npm ERR! file sh
...
Any ideas? Thank you!