F5 Programmability Training > Class 2: Building Continuous Delivery Pipelines > Module 4: Continuous Integration / Continuous Delivery Source | Edit on

Lab 4.2 - Executing Jenkins Jobs for Creation or Modify

Now that we have Jenkins running, and the dependent Slack Plugin installed we can utilize our Jenkins Pipeline Scripts successfully.

Task 1 - Building the Application Service Framework via Jenkins

This step is executing the f5-newman-wrapper files. Instead of having to run the two different builds (Application Service Framework and Pool member add) individually we’ll use a pause. Jenkins has a pause functionality which pauses a deployment looking for an approval to continue. After the approving step the node will be added; using the 2 f5-newman-wrapper files, but in conjunction with a single solution (Jenkins). Jenkins will continue to update the class via Slack as people are progressing. Jenkins also keeps a running console for logging, which we will also review.

  1. From the Jenkins Dashboard click on create new jobs

    lab-2-1

  2. We are going to create our first Pipeline Job. Name the item module_4_jenkinsfile1-2, choose the Pipeline project style and select OK

    lab-2-2

  3. We are going to be using the raw Jenkinsfile1-2 right in the Pipeline Script option at the end of the config page. Scroll to the bottom of the page but please look at the other options which can deploy a Pipeline. The different options in here are for an SCM (like GitHub), the Polling or Commit methods enable Continuous Deployment, as Jenkins will deploy the change on an event basis. Tie this with automatic testing to make sure you’re not breaking the build!

    lab-2-3

  4. We need to enter the contents of the Jenkinsfile1-2 into the Script section under Pipeline. After the contents are added click the Save Option.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 node {
    stage('Testing') {
       //Run the tests
       //sh "python -m /home/snops/f5-automation-labs/jenkins/f5-newman-build/f5-newman-build-1"
       //sh "python -m /home/snops/f5-automation-labs/jenkins/f5-newman-build/f5-newman-build-2"
    }
    stage('Frameword-Deployment') {
        //Run SNOPS Container Newman Package Virtual and Pool
       sh "f5-newman-wrapper /home/snops/f5-automation-labs/jenkins/f5-newman-build/f5-newman-build-1"
       //chatops slack message that run has completed
       slackSend(
          channel: '#jenkins_builds',
          color: 'good',
          message: 'Super-NetOps Engineer is about to deploy an F5 Service Framework, Approval Needed!',
          teamDomain: 'f5agilitydevops',
          token: 'vLMQmBq2tiyiCcZoNlbmAi0Z'
          )
    }
    stage('Approval') {
       //Gate the process and require approval
       input 'Proceed?'
       //chatops slack message that run has completed
       slackSend(
           channel: '#jenkins_builds',
           color: 'good',
           message: 'Super-NetOps Engineer just approved a new F5 Service Framework, thats some serious Continuous Delivery!',
           teamDomain: 'f5agilitydevops',
           token: 'vLMQmBq2tiyiCcZoNlbmAi0Z'
           )
    }
    stage('Add-Sevice-Node') {
        //Run SNOPS Container Newman Package add Node to Pool
       sh "f5-newman-wrapper /home/snops/f5-automation-labs/jenkins/f5-newman-build/f5-newman-build-2"
       //chatops slack message that run has completed
       slackSend(
          channel: '#jenkins_builds',
          color: 'good',
          message: 'Super-NetOps Engineer just added a Node to a Service, Production is Online!',
          teamDomain: 'f5agilitydevops',
          token: 'vLMQmBq2tiyiCcZoNlbmAi0Z'
          )
    }
 }

Contents in Pipeline:

lab-2-4

  1. Once the Job is saved, you will be taken to the stage view page, from here we are going to execute our Pipeline build, choose the Build Now option.

    lab-2-5

  2. The Build is now running, and the stages are being executed in order. However, on our third stage we have a pause and an approval needed. Also at the same time Slack has began to notify us that a new service is being deployed, and someone needs to approve it.

    lab-2-6 Highlight over the third Stage to prompt for the Approval lab-2-7

    lab-2-8

  3. Approve the change in Jenkins to allow the build to finish. Once this is done, the approval and finished Slack notification will be sent.

    lab-2-9

    lab-2-10

  4. At the end of the Build event (success or failure) there is a console output from Jenkins. Select the blue globe on the left to see the outputs

    lab-2-11

  5. The Console Output file not only contains the Jenkins output from the Build, but also the f5-newman-wrapper toolkit logs for easy troubleshooting

    lab-2-12

  6. Check Slack for the completion of everything!

    lab-2-13

  7. Verify on the BIG-IP that the pool module_3_vs has been created and the services are Green

    lab-2-15

Task 2 - Jenkinsfile3 and Jenkinsfile4

These two Jenkins files were completed to show the ability of creating smaller deployments. In our case we will use the f5-newman-wrapper toolkit to again change the user selected state of a pool member. The different Pipelines notifications also have different Slack Color depictions, helping to quickly identify issues to team members.

  1. Return to the Jenkins Dashboard and select New Item

    module-4-1

  2. Repeat steps 2 & 3 of the last module, creating 2 new Jenkins jobs, one for each desired node state.

  3. Create and Execute module_4_jenkinsfile_3 for a down node

    Pipeline Job Name: module_4_jenkinsfile_3

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    node {
      stage('Testing') {
         //Run the tests
         //sh "python -m /home/snops/f5-automation-labs/jenkins/f5-newman-operation/f5-newman-build-3"
      }
      stage('Disable-Node') {
          //Run SNOPS Container Newman Package Virtual and Pool
         sh "f5-newman-wrapper /home/snops/f5-automation-labs/jenkins/f5-newman-operation/f5-newman-build-3"
         //chatops slack message that run has completed
         slackSend(
            channel: '#jenkins_builds',
            color: 'bad',
            message: 'Super-NetOps Engineer just disabled a Service Node!',
            teamDomain: 'f5agilitydevops',
            token: 'vLMQmBq2tiyiCcZoNlbmAi0Z'
            )
      }
    }
    
  4. Verify on the BIG-IP that the pool module_3_pool has a down node

  5. Create and Execute module_4_jenkinsfile_4 for an up node

    Pipeline Job Name: module_4_jenkinsfile_4

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    node {
      stage('Testing') {
         //Run the tests
         //sh "python -m /home/snops/f5-automation-labs/jenkins/f5-newman-operation/f5-newman-build-4"
      }
      stage('Enable-Node') {
          //Run SNOPS Container Newman Package Virtual and Pool
         sh "f5-newman-wrapper /home/snops/f5-automation-labs/jenkins/f5-newman-operation/f5-newman-build-4"
         //chatops slack message that run has completed
         slackSend(
            channel: '#jenkins_builds',
            color: 'good',
            message: 'Super-NetOps Engineer just enabled a Service Node!',
            teamDomain: 'f5agilitydevops',
            token: 'vLMQmBq2tiyiCcZoNlbmAi0Z'
            )
      }
    }
    
  6. Verify on the BIG-IP that the pool module_3_pool has an up node