CONTROLLED DATA
Leidos Proprietary - US Citizens ONLY
The information contained herein is proprietary to Leidos, Inc. It may not be used, reproduced, disclosed, or exported without the written approval of Leidos.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

An agent in our implementation of Jenkins is a pre-defined set of Docker images that can be used to perform a build step. The following snippet demonstrates declaring an agent and using the agent in a build step. Note that this is not a full pipleine, just the code that relates to an agent. 

...
  agent { 
    node { 
      label 'docker-builder'
    } // end node
  } // end agent
...
    // run a Docker build
    stage ('Docker build') {
      steps {
        container('docker') {
          echo 'docker build'
          script {
            docker.withRegistry('https://REGISTRY.artifactory.sdodev.leidos.com/', 'CREDENTIAL'){
              docker.build('IMAGE:TAG', '.')
            } // end docker
          } // end script
        } //end container
      } // end steps
    } //end stage

Notes:

Line 4: The agent is used to build Docker images. Please see the list of other agents below that have been configured.

Line 11:  An agent consists of one or more additional Docker containers. Some commands will only work when issued from within the selected container. This step is selecting the container named 'docker' which contains the the Docker CLI.

Line 14: This line selects the registry from which layers will be pulled when building images. Since we are using private registries, a set of credentials are needed for docker to log into the registry.

Line 15: This will build an image (the first parameter) setting the current directory as the Docker context (the second parameter).

Important: This stage will build the image but not upload the image to a registry. The code snippet below will upload the built image to a registry:

    // push image
    stage ('Docker push latest') {
      steps {
        container('docker') {
          
          script{
            docker.withRegistry('https://REGISTRY.artifactory.sdodev.leidos.com/', 'CREDENTIAL'){
              docker.build('IMAGE:TAG')
            } //end docker
		  } //end script
        } // end container
      } // end steps
    } //end stage

   Additional Agents available in Jenkins

The following additional Agents are configured in Jenkins:

Namepurpose
defaultThe default agent, provides a JNLP connection back to Jenkins, contains maven and a JDK
docker-builderContains an image with the Docker CLI for building Docker images
taurusContains a Taurus image for running various test automations. A default JMeter automation framework is available in this image
xl-builderSimilar to default but allocates more CPU and memory resources. Some Gradle builds will not run in the 'default' agent.


  • No labels