--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5ca8978f-78ed-468a-8050-f7193df7f5c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sorry for late answer from me. Thank you for your solution. Really appreciate. It's really hard subject for me (not long time ago I have only heard about something like Jenkins and Docker). Currently I have:1. Multibranch Pipeline.2. Dockerfile is inside project folder. What is "Jenkins ChangeSet" - do you mean "currentBuild.changeSets"? Why and how should I change dockerfile during pipeline execution? :)
3. Currently I made own image of jenkins slave based on https://hub.docker.com/r/jenkinsci/jnlp-slave/ + installed postgres, rail, ruby. Whole multibranch pipeline works perfect (build with success) on this slave.
4. Do you run build/test using some plugin or by adding something to Jenkinsfile or maybe something another?
5. Honestly, also no idea how... :/
Dockerfile
FROM ubuntu:16.04
RUN apt-get -y update && apt-get install -y \ sudo \ openssh-server \ openssl \ openjdk-8-jre \ git
RUN adduser --disabled-password --gecos "" --uid 1000 jenkins \ && adduser jenkins sudo \ && mkdir /home/jenkins/slave && echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN curl -L https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.9/swarm-client-3.9.jar \ -o /home/jenkins/slave/swarm-client-3.9.jar
USER jenkins
====================
Jenkinsfile
node('docker_host') {
stage('Prepare Env') {
def imgID = sh(script: "docker images -q ${imgName}", returnStdout: true)
if ((imgID == null) || (imgID == '')) {
sh(script: "docker build -t ${imgName} -q -f ${dockerfile} ./")
}
def cmd = "java -jar /home/jenkins/swarm-client-3.9.jar -master ${env.JENKINS_URL} -username ${jenkins_user} -password ${jenkins_pwd} -labels ${docker_label} -name ${docker_build} -executors 1 -fsroot /home/jenkins"
sh """#!/bin/sh -e
docker run -td --name ${containerName} --volume ${map_volume} ${imgName} bash -c ${cmd}"""
}
}
node(docker_build) {
stage('Build') {
// Do your build and test here
}
}
node('docker_host') {
// Cleanup your docker container and image
}pt., 24 maj 2019 o 03:17 Quang Truong <truongdi...@gmail.com> napisał(a):
We implemented a similar Use Case:--
- Create an isolate environment for each team
- Whenever they have commit/PR triggers a build and create a container to build that project.
- If the Dockerfile in that project has changed, refresh the docker image then create container based on the new image.
The solution is (refer and tailor on your case):
- Use multibranch project so Jenkins will trigger with git commit/PR
- Put Dockerfile into the project folder (let the team maintains their environment), use the Jenkins ChangeSet to verify if the Dockerfile has changed so you will refresh (remove the existing image then build a new one with the updated Dockerfile) the docker image on your Jenkins executor
- Build the docker image/container as a Jenkins slave (use swarm-client, accept the security issue with this plugin)
- Run the build/test the project on your new slave container (consider about concurrent pipeline with the new container)
- If the build is green, back to the slave/host then push/update the image into the docker registry
Hope this can help
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5ca8978f-78ed-468a-8050-f7193df7f5c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Pozdrawiam / Kind regards,
Piotr Bracha
Administrator SystemówVasco Electronics sp. z o.o. S.K.A.
al. Pokoju 1, CTA/350
31-548 Kraków
NIP 677 236 91 51
E-mail: p.b...@vasco-electronics.com
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/752ad51e-a9e0-45d7-a892-2c2407920c45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.