06.03
- 6.3 Configure a scripted environment job
- Learning Objectives
- EXERCISE: Create a Jenkins job that builds a new environment
6.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.
EXERCISE: 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.
- Select the checkbox next to This build is parameterized. Enter a String Parameter type and give it the name STACK_NAME. Enter your student id for the Default Value text field.
- Enter another String Parameter type and give it the name PrivateBucket. Enter cd29creds (where 29 is your student id) for the Default Value text field.
- Enter another String Parameter type and give it the name PublicBucket. Enter cd29artifacts (where 29 is your student id) for the Default Value text field.
- Enter another String Parameter type and give it the name KeyName. Enter cd29 (where 29 is your student id) for the Default Value text field.
Under the Source Code Management section, select the Git radio button. In the Repository URL field, enter your forked repository URL. Yours will be something like student03, student08, etc. For example:
git@github.com:student29/continuous_integration_example.git
In the Branches to build | Branch Specifier field, enter **
- Within the Build Environment section, click on the Create AWS Cloud Formation stack checkbox.
In the Cloud Formation recipe file. (.json) field, enter:
software/infrastructure/target.template
In the Stack name field, enter:
${STACK_NAME}
In the Stack description field, enter:
stack
Leave Cloud Formation parameters field, enter:
PrivateBucket=${PrivateBucket},PublicBucket=${PublicBucket},KeyName=${KeyName}
In the Timeout (seconds) field, enter:
900
In the AWS Access Key field, enter:
$AWS_ACCESS_KEY
In the AWS Secret Key field, enter:
$AWS_SECRET_ACCESS_KEY
Leave 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.
ruby /usr/share/tomcat6/scripts/aws/create_domain.rb ${STACK_NAME} echo "artifact_bucket=$(eval "echo \$${STACK_NAME}_ArtifactBucket")" >> /tmp/properties echo "ip_address=$(eval "echo \$${STACK_NAME}_InstanceIPAddress")" >> /tmp/properties echo "stack_name=$(eval "echo \$${STACK_NAME}_StackName")" >> /tmp/properties ruby /usr/share/tomcat6/scripts/aws/load_domain.rb ${STACK_NAME}
Click the Save button.
- Go back to the Jenkins dashboard and click the Build button next to the MyTargetEnvironment job.