6.4 Configure a scripted build job

Learning Objectives

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

EXERCISE: Create a scripted build job in Jenkins

  1. From the Jenkins dashboard, select the New Job link.
  2. Enter MyBuild 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:student29/continuous_integration_example.git. Yours will be something like:
    git@github.com:student29/continuous_integration_example.git
  4. In the Branches to build | Branch Specifier field, enter master.
  5. In the Build Triggers section, select the checkbox next to Poll SCM and enter following in the Schedule text field.
    * * * * *
  6. Within the Build section, enter the following 2-line command in the Execute shell text field.
    cd software
    ant -f build.xml
  7. 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
  8. Click the Save button.
  9. 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)

  1. From the Jenkins dashboard, select the New Job link.
  2. Enter MyBuild 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:student29/sample_app.git. Yours will be something like:
    git@github.com:student29/sample_app.git
  4. In the Branches to build | Branch Specifier field, enter master.
  5. In the Build Triggers section, select the checkbox next to Poll SCM and enter following in the Schedule text field.
    * * * * *
  6. Within the Build section, enter the following two-line command in the Execute shell text field.
    ruby -v
    bundle install
  7. 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/
  8. Within the Build section, enter the following command in the Execute shell text field.
    tar -czf continuousdelivery.tar.gz *
  9. 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
  10. Click the Save button.
  11. Go back to the Jenkins dashboard and click the Build button next to the MyBuild job.