Configure Selenium Jenkins job with Ruby Env setup from Jenkins User

Note: (Follow this post before proceeding)

  • Start with creating a new Jenkins job by clicking Jenkins > New Item
  • Enter the job name, select Freestyle project, and click ok

  • Choose Source Code Management > Git and enter the prompt GitHub repo. Enter the branch name if different.

  • Now, select Build > Add build step > Execute shell

  • And follow these steps in shell to run selenium cucumber tests
  1. Set temporary RVM environment setup
  2. source /var/lib/jenkins/.rvm/bin/rvm

    or

    source ~/.rvm/bin/rvm
  3. Create rvm gemset and switch to it
  4. rvm gemset create test
    rvm gemset use test
  5. Install the ruby libraries
  6. gem install bundler
    bundle install
  7. Run Selenium cucumber tests
  8. cucumber features/scenarios/**/*.feature
  9. Finally, apply changes

Skip the manual temporary RVM environment setup [Optional]

  • Go to Manage Jenkins > Manage Plugins, click on the Available tab
  • Enter rvm in the filter

  • Select checkbox, download & restart Jenkins to take effect
  • Now, open the job created earlier and click Configure

  • you’ll see an extra newly added option, Run the build in a RVM-managed environment under Build Environment section

  • Add the installed ruby version in it (say, ruby-2.4.1) and remove source ~/.rvm/bin/rvm from the Execute shell

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s