Java, Maven and Angular in one image

I have a project based on Java Spring Boot and Angular. In the maven pom.xml I call “ng build” externally.
And I get error upon running maven on this pom.xml:

java.io.IOException: Cannot run program “ng” (in directory “/drone/src/src/main/frontend”)

folder “/drone/src/src/main/frontend” exists, I checked that, so I suppose, that drone is unable to find ng executable in the maven image. My .drone.yml looks like that:

kind: pipeline
name: default

steps:

  • name: Install Angular
    image: node
    commands:

    • npm install -g @angular/cli
    • ls
    • pwd
    • cd src/main/frontend
    • npm install
    • cd /drone/src/src/main/frontend
    • ng --version
  • name: test
    image: maven:3-jdk-8
    commands:

    • mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
    • mvn test -B

Part of my pom.xml where I call “ng build”

		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>exec-maven-plugin</artifactId>
			<version>1.6.0</version>
			<executions>
				<execution>
					<phase>validate</phase>
					<goals>
						<goal>exec</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<executable>ng</executable>
				<workingDirectory>src/main/frontend</workingDirectory>
				<arguments>
					<argument>build</argument>
				</arguments>
			</configuration>
		</plugin>

My questions:
Is it possible to make angular available for the maven image? When I run “ng --version” on the node image, it runs ok. But when I run “ng build” from my pom.xml file, that is processed in maven image, I get the error I described above.

Or for such kind of projects I should not use isolated images and use ‘exec pipeline’ approach: Overview | Drone

Am I right?

Thank you.

the recommend solution is to build and publish your own docker image, with all the tools and software you need, so that you can use the image in your pipeline

1 Like

Thank you for your help :slight_smile: