Reputation: 1309
I have started learning jenkins by using jenkinsci/blueocean docker image. Turns out this image does not have maven installed. I followed Maven Installation on Jenkins Docker Container link to install maven from a .gz file. It did not work.
Can anybody tell me how to install maven inside jenkinsci/blueocean container.
Thanks in advance.
Upvotes: 0
Views: 3363
Reputation: 897
The jenkins/blueocean image is based on Alpine Linux. You can check this by running
cat /etc/*-release
inside the container.
To install packages on Alpine Linux you will need to use the apk package manager. For example:
apk add --no-cache package_name
However, to successfully run this you need to access the container as root. This can be achieved by running the command below:
docker exec --user root -it container_ID bash
You can then install maven in the jenkins/blueocean container by running the command:
apk add --no-cache maven
Upvotes: 1
Reputation: 946
Jenkins Blueocean docker image is based on Alpine Linux (Found this by running cat /etc/*-release
from inside the image via Portainer).
Alpine uses apk as the package manager/installer. So
apk add maven
to install maven. This worked and Jenkins step in workflow script sh mvn clean install
could execute successfully.EDIT The alternative and much better way would be to use a separate maven docker container as Jenkins agent as suggested in the tutorial documentation here:
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
}
}
Upvotes: 2