Answers: <p>Using Docker with Jenkins in a situation like this is a great way to </p>
  
  <ol>
  <li>Keep Jenkins worker slave nodes clean (so you don't have to build or install anything on them)</li>
  <li>Have all dependencies and environment in an easily manageable artifact (in this case, a docker image is the snapshot of the exact OS, filesystem, env and dependencies) </li>
  <li>Vendor / keep copies of dependencies at a certain point in time (Example: You don't want to update at the same rate as the dependency)</li>
  </ol>
  
  <p>If you have some kind of artifact management system (Example: Nexus) you can store your docker images in the artifact management system, and then pull them into Jenkins, and create a running container that has your repository in it. From there you can build project run tests inside the docker image. Just be sure you remember to move/copy all test results and built artifacts out of the docker container if you need them or use them later. </p>
  
  <p>If you need more details or specifics please edit your question and I will edit my answer accordingly.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-04-15T18:28:13.800Z
Answers: 2019-04-15T18:28:13.800Z
Answers: Wimateeka
Body: <p>I have a <a href="http://www.ros.org/" rel="nofollow noreferrer">ROS</a> project for which I'm looking to use Jenkins to set up a CI system.</p>
  
  <p>The project has a large number of dependencies which take a long time to build (they can't be installed on the build executor machines), so we typically build them once, then let Catkin (ROS's build system, based on CMake) use the cached artifacts on subsequent builds.</p>
  
  <p>The Jenkins setup we currently have does this:</p>
  
  <ul>
  <li>Clone repository at commit</li>
  <li>Create an empty Catkin workspace</li>
  <li>Clone and setup all our dependencies</li>
  <li>Build everything together</li>
  <li>Run tests</li>
  </ul>
  
  <p>Due to building all our dependencies, this takes several hours.</p>
  
  <p>What I'd like to do is this:</p>
  
  <ul>
  <li>Clone repository at commit</li>
  <li>Move it into an already built Catkin workspace containing all dependencies</li>
  <li>Build just our project</li>
  <li>Run tests</li>
  </ul>
  
  <p>I was thinking of setting up a Docker container with all the dependencies ready to go, and then just running the build in that. Is that a typically recommended approach?</p>
  
Tags: <docker><jenkins>
Title: Is there an alternative to setting up the whole project workspace in a Jenkinsfile
UserDisplayName: Omegastick
ThreadText: # Is there an alternative to setting up the whole project workspace in a Jenkinsfile
  
  (Asked by: username_0 on 2019-02-13)
  
  I have a [ROS](http://www.ros.org/) project for which I'm looking to use Jenkins to set up a CI system.
  
  The project has a large number of dependencies which take a long time to build (they can't be installed on the build executor machines), so we typically build them once, then let Catkin (ROS's build system, based on CMake) use the cached artifacts on subsequent builds.
  
  The Jenkins setup we currently have does this:
  
  * Clone repository at commit
  * Create an empty Catkin workspace
  * Clone and setup all our dependencies
  * Build everything together
  * Run tests
  
  Due to building all our dependencies, this takes several hours.
  
  What I'd like to do is this:
  
  * Clone repository at commit
  * Move it into an already built Catkin workspace containing all dependencies
  * Build just our project
  * Run tests
  
  I was thinking of setting up a Docker container with all the dependencies ready to go, and then just running the build in that. Is that a typically recommended approach?
  
  **Tags:** docker, jenkins
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-15. Score: 1
  
  Using Docker with Jenkins in a situation like this is a great way to
  
  1. Keep Jenkins worker slave nodes clean (so you don't have to build or install anything on them)
  2. Have all dependencies and environment in an easily manageable artifact (in this case, a docker image is the snapshot of the exact OS, filesystem, env and dependencies)
  3. Vendor / keep copies of dependencies at a certain point in time (Example: You don't want to update at the same rate as the dependency)
  
  If you have some kind of artifact management system (Example: Nexus) you can store your docker images in the artifact management system, and then pull them into Jenkins, and create a running container that has your repository in it. From there you can build project run tests inside the docker image. Just be sure you remember to move/copy all test results and built artifacts out of the docker container if you need them or use them later.
  
  If you need more details or specifics please edit your question and I will edit my answer accordingly.
  
  
  ---
  
  