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
- From the Jenkins dashboard, select the New Job link.
- Enter MyTargetEnvironment in the Job name field. Click on the Build a free-style software project radio button and click the OK button.
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.gitIn the Branches to build | Branch Specifier field, enter master.
- Within the Build Environment section, click on the Create AWS Cloud Formation stack checkbox.
In the Cloud Formation recipe file. (.json) field, enter:
infrastructure/templates/target.templateIn the Stack name field, enter:
testIn the Stack description field, enter:
test stackLeave Cloud Formation parameters field blank.
In the Timeout (seconds) field, enter:
2500In the AWS Access Key field, enter:
$AWS_ACCESS_KEYIn the AWS Secret Key field, enter:
$AWS_SECRET_ACCESS_KEYLeave the Automatically delete the stack when the job completes checkbox unchecked:
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}Click the Save button.
- Go back to the Jenkins dashboard and click the Build button next to the MyTargetEnvironment job.