Docker containers as Jenkins Slave build agents

0 votes
i have a jenkins master running inside a container ... and i'm tyring to containerize my builds using Docker containers as Jenkins Slave (build agents), on a separete vm , to run my CI pipelines. This Docker container (build agents) will be created when the CI pipeline runs; . once the build is complete the Docker container will be destroyed. To achieve this:


i use docker plugin as following:

enter image description here

this my jenkinsfile code:

node('docker') { stage('Checkout Code') { checkout scm } stage('Build') { withMaven { sh 'mvn clean install' } } }

when i run my peline every thing is going right :

but the question is about the build results (.war)
are this archives transferred to the master workspace or destroyed with the container ?? if the second case then how can i recuperate the build results to jenkins master to pursue CI process ??

[INFO] Installing /home/jenkins/workspace/Build_pipeline_team/target/Teams.war to /home/jenkins/.m2/repository/teams/Teams/1.0-SNAPSHOT/Teams-1.0-SNAPSHOT.war [INFO] Installing /home/jenkins/workspace/Build_pipeline_team/pom.xml to /home/jenkins/.m2/repository/teams/Teams/1.0-SNAPSHOT/Teams-1.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:12 min [INFO] Finished at: 2017-11-15T03:40:13+00:00 [INFO] Final Memory: 21M/51M [INFO] ------------------------------------------------------------------------ [jenkins-maven-event-spy] INFO generated /home/jenkins/workspace/Build_pipeline_team@tmp/withMaven673f8d6e/maven-spy-20171115-033800-6375412806014049683204.log [Pipeline] } [withMaven] artifactsPublisher - Archive artifact pom.xml under teams/Teams/1.0-SNAPSHOT/Teams-1.0-SNAPSHOT.pom [withMaven] artifactsPublisher - Archive artifact target/Teams.war under teams/Teams/1.0-SNAPSHOT/Teams-1.0-SNAPSHOT.war [withMaven] junitPublisher - Archive test results for Maven artifact teams:Teams:1.0-SNAPSHOT generated by maven-surefire-plugin:test (default-test): target/surefire-reports/*.xml

Can anyone help me with this query?

Jun 16, 2018 in Docker by Atul
• 10,220 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

When you encapsulate the stage inside a node, everything will run on that node. Thus the war will ne destroyed with the container when the build finished.

You have several alternatives to keep the war.

The maven way is to deploy artifacts to a repisitory such as nexus.

Another jenkins alternative is to stash the war on the slave once the build finishes and un stash it back on the master. This will effectively copy back the stashed files from the slave to the master node.

answered Jun 16, 2018 by Atul
• 10,220 points

Related Questions In Docker

0 votes
1 answer

build an J2EE application with docker

I would suggest you to use volume ...READ MORE

answered May 1, 2018 in Docker by shubham
• 6,560 points
+1 vote
2 answers

How to run docker containers on different machines

You can use labels and selectors for ...READ MORE

answered Oct 23, 2018 in Docker by Laila
0 votes
1 answer

Docker : multiples linked containers for each customers

Using Docker (specifically Docker Compose) linking containers ...READ MORE

answered Jul 11, 2018 in Docker by Kalgi
• 2,620 points
+13 votes
2 answers
0 votes
1 answer
+1 vote
5 answers

Set containers timezones by using docker compose.

version "2" services: serviceA: ...READ MORE

answered Jul 8, 2018 in Docker by Atul
• 10,220 points
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,100 points

edited Oct 16, 2018 by lina 2,463 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.