Balaji Vajjala's Blog

A DevOps Blog from Trenches

04

  • 4.3 Configure a scripted environment job
    • Learning Objectives
    • Create a Jenkins job that builds a new environment

4.3 Configure a scripted environment job

Learning Objectives

By the end of this lesson you will be able to:

  • Create a new job in Jenkins that builds an environment using the AWS infrastructure and CloudFormation.

Create a Jenkins job that builds a new environment

  1. From the Jenkins dashboard, select the New Job link.
  2. Enter MyTargetEnvironment in the Job name field. Click on the Build a free-style software project radio button and click the OK button.
  3. Under the Source Code Management section, select the Git radio button. In the Repository URL field, enter your forked repository URL. Mine is git@github.com:stelligent/devopsinthecloud.git. Yours will be something like:

    git@github.com:YourUsername/devopsinthecloud.git

  4. In the Branches to build | Branch Specifier field, enter master.

  5. Within the Build Environment section, click on the Create AWS Cloud Formation stack checkbox.
  6. In the Cloud Formation recipe file. (.json) field, enter:

    infrastructure/templates/target.template

  7. In the Stack name field, enter:

    test

  8. In the Stack description field, enter:

    test stack

  9. Leave Cloud Formation parameters field blank.

  10. In the Timeout (seconds) field, enter:

    2500

  11. In the AWS Access Key field, enter:

    $AWS_ACCESS_KEY

  12. In the AWS Secret Key field, enter:

    $AWS_SECRET_ACCESS_KEY

  13. Leave the Automatically delete the stack when the job completes checkbox unchecked:

  14. Within the Build section, enter the following command in the Execute shell text field.

    cucumber $WORKSPACE/infrastructure/features/target.feature env_ip=${test_InstanceIPAddress} env_user=ec2-user ruby /usr/share/tomcat6/sqs_send_message.rb Deployment $AWS_ACCESS_KEY $AWS_SECRET_ACCESS_KEY ${test_InstanceIPAddress} ruby /usr/share/tomcat6/sqs_send_message.rb CloudFormationStacks $AWS_ACCESS_KEY $AWS_SECRET_ACCESS_KEY ${test_StackName}

  15. Click the Save button.

  16. Go back to the Jenkins dashboard and click the Build button next to the MyTargetEnvironment job.