Wednesday 23 September 2015

Part 8 -- Setup Jenkins and gerrit: Running a job in response to commit on gerrit

Lets create another job called extended_tests on Jenkins. Purpose of this job is to run a set of test cases (in our case, set will contain only one test) whenever new commit arrives on gerrit.

  1. Go to Jenkins address.
    New-Item   -->  Freestyle-Project.
  2. Under Build-Trigger. Check "gerrit event".
  3. Use builder under project name. And master under Branches.

  4. Under "Build" --> Execute Shell, Add following script
    echo "USER=$USER, HOME=$HOME, WORKSPACE=$WORKSPACE, REFSPEC=$GERRIT_REFSPEC"
    cd ${WORKSPACE}
    git clone http://jenkins1@10.10.0.19:8080/builder && scp -p -P 29418 jenkins1@10.10.0.19:hooks/commit-msg builder/.git/hooks/
    cd builder
    bash job_script.sh
  5. Commit a patchset on builder.
  6. You will see that a pipeline will get triggered automatically.
NOTE: You might need to install Workspace Cleanup Plugin to jenkins. 

No comments:

Post a Comment