Setting up Your Jenkins Projects
Table of Contents
1 Adding Git Credentials
- While in your folder.
- Select "Credentials" in the right hand sidebar.
- Select "Global credentials (unrestricted)" Note: these credentials are only available to projects in your folder.
- generate ssh-keys.
- Add credentials.
- kind: "SSH username with private key"
- username: your github user name.
- Private key: Enter directly and then copy/paste a key. Make sure the public part of the key is on your GitHub account.
- Passphrase: your passphrase.
- Description:
2 Create New Project
- select your folder.
- Select "New Item".
- Create Freestyle project
- Project name.
- Select: "Restrict where this project can be run" - use the node name sent to you e.g. tiger_netid. Note: there should be no white space after the node name.
- Source Code Management:
- select git
- Repository:
git@github.com:PrincetonUniversity/HelloWorld.git
- Credentials: select from the list.
- Repository:
- select git
- Build trigger: Select
Poll SCM
and enter something likeH/15 * * * *
to poll every 15 min. - Build examples:
- Execute shell on the head node:
compile:
#!/bin/bash module load intel/16.0 module load intel-mpi/intel icc -o hello hello.c
execute simple command
#!/bin/bash ./hello > tmp cat << EOF > good.txt Hello world!! EOF diff tmp good.txt
Use slurm for longer tests:
#!/bin/bash cd /home/luet/hello salloc -N1 -n1 --time=1 ./test.sh
- Execute shell on the head node:
compile:
- Post-build Actions: e-mail notifications:
- Add the list of emails: e.g. luet@princeton.edu
- Triggers: You can specify to always send the e-mails.
3 GitHub Pull-Request Trigger
3.1 Modifications to your GitHub Repo
- Add
buildbot-princeton
as a collaborator to your repo. It needs to be able to clone the repo and add comments on the Pull-request. Giving it write permissions will achieve that. - Create a WebHook:
- URL: https://jenkins.princeton.edu/ghprbhook/
- Events for which to trigger this webhook:
- Pull Request
- Issue comment
3.2 Modifications To Your Jenkins's Job Config
When configuring your job:
- Select
GitHub project
, enter the project url - In Source code management, select
Git
and enter the Repository URL e.g.
git@github.com:PrincetonUniversity/HelloWorld.git
- Pick your credential.
- Branches to build, type:
${sha1}
- click the
Advanced
button and in theRefspec
box enter:+refs/pull/*:refs/remotes/origin/pr/*
- click the
- Repository browser: githuweb
- Build Triggers
- Select
GitHub Pull Request Builder
- Select
Use github hooks for build triggering
- You can list GitHub names in white list.
- Select
3.3 What Happens When Someone Opens A Pull-Request
- If the developer is whitelisted, the test is run automatically. The status of the Jenkins test is shown on the GitHub Pull-Request page.
- If the developer is not whitelisted, Jenkins comments on the GitHub Pull-Request page: "Can one of the admins verify this patch?". The three options are:
- "ok to test" to accept this pull request for testing
- "test this please" for a one time test run
- "add to whitelist" to add the author to the whitelist
If the build fails for other various reasons you can rebuild with "retest this please" to start a new build.
See GitHub pull request builder plugin for more details.