06.04
- 6.4 Configure a scripted build job
- Learning Objectives
- EXERCISE: Create a scripted build job in Jenkins
- EXERCISE: Create a scripted build job in Jenkins (OPTIONAL)
6.4 Configure a scripted build job
Learning Objectives
By the end of this lesson you will be able to:
- Create a Jenkins job that runs a scripted build.
EXERCISE: Create a scripted build job in Jenkins
- From the Jenkins dashboard, select the New Job link.
- Enter MyBuild 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:student29/continuous_integration_example.git. Yours will be something like:
git@github.com:student29/continuous_integration_example.git
In the Branches to build | Branch Specifier field, enter master.
In the Build Triggers section, select the checkbox next to Poll SCM and enter following in the Schedule text field.
“`
“`
Within the Build section, enter the following 2-line command in the Execute shell text field.
cd software ant -f build.xml
in the Post-build Actions section, select the Publish artifacts to S3 Bucket checkbox. Enter target/deployment/brewery.war in the Source field and cd29artifacts (where 29 is your student id) in the Destination bucket field
- Click the Save button.
- Go back to the Jenkins dashboard and click the Build button next to the MyBuild job.
EXERCISE: Create a scripted build job in Jenkins (OPTIONAL)
- From the Jenkins dashboard, select the New Job link.
- Enter MyBuild 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:student29/sample_app.git. Yours will be something like:
git@github.com:student29/sample_app.git
In the Branches to build | Branch Specifier field, enter master.
In the Build Triggers section, select the checkbox next to Poll SCM and enter following in the Schedule text field.
“`
“`
Within the Build section, enter the following two-line command in the Execute shell text field.
ruby -v
bundle install
Within the Build section, enter the following 4-line command in the Execute shell text field.
ruby -v
rake db:migrate
rake db:test:prepare
rspec spec/
Within the Build section, enter the following command in the Execute shell text field.
tar -czf continuousdelivery.tar.gz *
in the Post-build Actions section, select the Publish artifacts to S3 Bucket checkbox and enter an S3 bucket you have privileges to. Enter continuousdelivery.tar.gz in the Source field and the name of the bucket you have access to in the Destination bucket field
- Click the Save button.
- Go back to the Jenkins dashboard and click the Build button next to the MyBuild job.