Configuring Jenkins jobs

Prior to recreating the Continuous Integration pipeline job, we need a S3 bucket for our YUM repository. Create a bucket (unless you've kept the old one around), update the demo-app/Jenkinsfile script accordingly then commit and push Git changes upstream.

demo-app pipeline

Refer to the Setting up the pipeline steps from the previous chapter to create the Continuous Integration job. Let us call it demo-app this time around. The script path remains the same (https://git-codecommit.us-east-1.amazonaws.com/v1/repos/demo-app).

You should now have this:

demo-app pipeline

The pipeline is going to fail as we do not have our YUM repository configured yet:

demo-app pipeline

The repository contents have already been uploaded to S3 by this first job run. Now we need to update the salt/states/yum-s3/files/s3.repo file with the S3 URL and set the repository to enabled. Commit and push the Salt changes to the Git repository, then pull and apply on the Jenkins node.

A subsequent pipeline run takes us a step further:

demo-app pipeline

This time the failure is because our downstream job is not quite ready yet. Let us fix that next.

demo-app-cdelivery pipeline

From the Jenkin's dashboard, we select  New Item:

demo-app-cdelivery pipeline

We shall call it demo-app-cdelivery:

demo-app-cdelivery pipeline

This job will be triggered by another one, so no need to poll SCM. Also, we have a parameter being passed to this pipeline:

demo-app-cdelivery pipeline

Finally, we set the location of the Jenkinsfile (https://git-codecommit.us-east-1.amazonaws.com/v1/repos/demo-app-cdelivery):

demo-app-cdelivery pipeline

Do you remember the VPC details we specified in the Packer variables file and also the Jenkinsfile for this pipeline? We need to set those to match our current VPC:

  • Update the variables in packer/demo-app_vars.json
    • srcAmiId could be the latest AmazonLinux AMI
    • subnetId is the ID of the Private subnet
    • vpcId
  • Update demo-app-cdelivery/Jenkinsfile:
    • In the Deploy AMI stage:
      • secGroupis the ID of the demo-app security group
      • subnetIdis the ID of the Private VPC subnet as mentioned earlier

    • In Run AB test
      • elbUriis the endpoint address of the demo-app-elb ELB

  • Commit and push your changes.

Here, we are with our two pipelines ready for action:

demo-app-cdelivery pipeline

Let us trigger a demo-app run by changing the $full_name in demo-app/src/index.php. You should see it running after detecting the Git change. At the end of the run, it should trigger the downstream demo-app-cdelivery pipeline, and after another approximately10 minutes, there should be a brand new demo-app AMI waiting for you (check the AWS console).

Note

Please remember to delete any AWS resources used in the mentioned examples (VPC, EC2, S3, IAM, CodeCommit, and so on) to avoid unnecessary charges.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset