Balaji Vajjala's Blog

A DevOps Blog from Trenches

04

  • 4.4 Configure a scripted build job
    • Learning Objectives
    • Create a scripted build job in Jenkins

4.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.

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:stelligent/sample_app.git. Yours will be something like:

    git@github.com:YourUsername/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 devopsinthecloud.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 devopsinthecloud.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.