Error happened while attempting to execute 'mvn clean package' in Go CD

387 Views Asked by At

I have setup a pipeline with one task mvn clean package in Go CD. I have registered an agent with Java and Maven up and running. When I trigger the pipeline, the job fails:

[go] Task: mvn clean package took: 0.14s Error happened while attempting to execute 'mvn clean package'. Please make sure [mvn] can be executed on this agent.

[Debug Information] Environment variable PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-11-openjdk/bin

I have tried all solutions provided on the below post-but nothing works Can't execute "mvn clean package" task in GO CD

2

There are 2 best solutions below

1
juice orange On

I encountered the same problem, If i execute docker exec -it gocd-agent bash and execute mvn --version,will not tip me error but if i execute docker exec -it gocd-agent sh,will tip me "mvn: command not found" so i feel the problem is bash and sh 'difference.

0
Daniel Ezihe On

Try this.

Run whereis mvn on your agent then copy the path where mvn is installed and use it as the command in GoCD.

For me it was like this:

Command

/opt/apache-maven-3.8.2/bin/mvn

Arguments

clean
package