Jenkins Slave can't read settings.xml
I have created a jenkins slave image for Docker, which I want to use to build all of my Java projects, however, I can’t work out how to reference the .m2/settings.xml file to tell it where to pull from.
My Dockerfile is:
FROM openjdk:8 MAINTAINER Chris Hudson <email@example.com> RUN apt-get -qqy update && \ apt-get -y install openssh-server sudo RUN useradd -m -u 1000 -s /bin/bash jenkins && \ mkdir -p /home/jenkins/.ssh && \ mkdir -p /home/jenkins/.m2 && \ echo jenkins:jenkins | chpasswd && \ mkdir -p /etc/sudoers.d/ && \ echo "jenkins ALL=(root) NOPASSWD: ALL" > /etc/sudoers.d/jenkins && \ chmod 440 /etc/sudoers.d/jenkins COPY id_rsa.pub /home/jenkins/.ssh/authorized_keys COPY settings.xml /home/jenkins/.m2/ RUN chown -R jenkins:jenkins /home/jenkins RUN mkdir -p /var/run/sshd EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]
But when I run the build, it attempts to pull from maven central, and not our local Artifactory instance, which is configured in the settings file.
This works when I run it on Jenkins Master, but I want to offload the builds to the slaves, but I can’t work out how to configure Maven correctly.
One Solution collect form web for “Jenkins Slave can't read settings.xml”
I think that your workspace is mounted from the slave. and it’s not read the .m2 from your container
you can try use his plugin – https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin to create the settings.xml and configure your MVN build step to use it.