Set up simulation in Docker

In this section of the guide, we will describe how to run a Fast Model simulation in Docker. You can use this method with any Jenkins install implementation, through apt on Linux or through Docker on any OS. Follow these steps:

  1. Click on the plus sign icon to create the first test stage, which will add two steps in the pipeline: running the Python script and checking its output. Give the file a name, for example, Test.
  2. Click on the add step > Shell Script buttons to add the following two steps:

    set +e && 
    . //root//ARM//FastModelsTools_11.3// &&
    set -e &&
    python //root//FMs// &&


    head //root//FMs//output.txt0

    Because Jenkins will run the Docker container non-interactively, you must source the Fast Models tools manually before you can run the Fast Model using Python. This is usually done on startup with .bashrc, which does not apply here because Jenkins does not run Docker commands in a login shell.

  3. Select the Test stage that you just created and can see at the bottom right of the screen, then select the Settings button.
  4. Set the Agent to docker and set the Image to zach/fm-m4-example:latest. This image is what was built in the previous section, Create and verify a Docker image. When running the Jenkins pipeline, that Docker image will be pulled and the shell scripts will run in the container that is created.

Each time that a change is made on the Blue Ocean GUI, the underlying Jenkinsfile changes, which dictates the pipeline behavior at runtime. To view the Jenkinsfile code, use the hotkey CTRL-S. You can edit the code using this method, which is helpful when the Blue Ocean GUI does not offer the necessary syntax option.

However, adding too much code that is not represented by the Blue Ocean GUI can be confusing, because your system behavior is hidden from the Blue Ocean GUI.

Now the pipeline script is set up and should look like what you can see in the following code:

pipeline {
  agent none
  stages {
    stage('Test') {
      agent {
        docker {
          image 'zach/fm-m4-example:latest'
      steps {
        sh '''set +e && 
. //root//ARM//FastModelsTools_11.3// &&
set -e &&
python //root//FMs//'''
        sh "head //root//FMs//output.txt0"
Previous Next