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
- 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:stelligent/sample_app.git. Yours will be something like:
git@github.com:YourUsername/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 devopsinthecloud.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 devopsinthecloud.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.