Comments (6)
The issue is related to the -u uid:gid
that jenkins uses to run the container. As you may know the image you are running only has the user root
created, so when jenkins pass its own uid and gid , there is no entry for the user and consequentially no $HOME
declared for it.
If you only want to run the build independently of the user, you can use the follow as agent:
agent {
docker {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2:z -u root'
reuseNode true
}
}
A few notes:
- if you notice the volume I am using with the flag
z
, as I am going to build with root, I need to tell docker that this volume will be shared among another containers, and then preventing access denied from my jenkins container (running with the user jenkins not root) - I tell jenkins to reuseNode, so any other stage using the same image, will be executing on the same container (it is just to speed up the provisioning time)
from docker-maven.
@gonzalesraul That works! Thank you for the help.
from docker-maven.
Is there any other workaround for it? Of course I want a new clean Maven container for each job run. And there must be a way to inject a custom settings.xml if container is not run as root.
In Jenkins, if the container is forced to run as root via
--user root:root
subsequent runs will fail as Jenkins is unable to delete generated directories.
Seems to be a long-time issue with this image, see: #14, #16, #18,
from docker-maven.
@steinsag yes, there is a few but I would suggest these below:
-
Instead of use declarative docker agent to run on jenkins you could use docker cli (using sh commands), and then you pass the parameters on your own. As I stated earlier, the issue is that docker agent always will bind jenkins uid:gid, consequentially there is no user on the target container. If took control of that part, you could run as root, mount the workspace or whatever (use
:z
option on docker to share info amongst different contexts) and then get the result after all. -
The other option involves extending the maven image by adding jenkins user and jenkins agent, and then use that extended image as docker agent on your pipeline. That way you would be fine once the user will exists and jenkins has the agent to run as usual.
from docker-maven.
I think this is an issue with jenkins, and somewhat fixed based on #16 (comment)
jenkinsci/docker-workflow-plugin#63 should have solved this without an image change.
from docker-maven.
@carlossg the issue resides on Jenkins for sure.
I think the root cause to getting these behaviors, resides on uid:gid
binding on Jenkins to the container startup.
Your mention to jenkinsci/docker-workflow-plugin#63 only resolves the entrypoint
option for scripted pipeline.
It still might not be on the maven container scope, but still a valid issue when used with docker-workflow-plugin
from docker-maven.
Related Issues (20)
- Maven 3.9, unauthorized 401 when reaching MS AZURE repo with PAT HOT 6
- Please update bash in Alpine image to avoid error message HOT 1
- Latest images don't have ssh causing maven-release-plugin to fail HOT 10
- Could not create local repository at /home/user/.m2/repository
- Please add amazoncorretto + al2023 images HOT 2
- How to get 3.9.4 released? HOT 1
- Wrong docer example for eclipse-temurin-17 version? HOT 1
- amazoncorretto-11-debian ignores environment variables with a period HOT 1
- ETA on JDK 21 compatible image
- Corretto 21 + AL2023 HOT 5
- Add Eclipse Temurin 21 HOT 1
- /usr/local/bin/mvn-entrypoint.sh: 50: exec: 1: not found HOT 2
- maven: 3.6.3-openjdk-21 HOT 1
- Add Apache Maven 3.9.6
- Image maven:3.8.8 missing
- Publish image with semeru jdk 21 HOT 1
- Image for maven 3.9.6 + azuluzulu-8 HOT 5
- 3.9.6-eclipse-temurin-21 and docker buildx
- Trouble with ${revision} in Docker builds HOT 1
- $JAVA_HOME is missing on amazoncorretto-8-debian HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-maven.