- The repository is private and is already integrated with Travis-CI.
- Jenkins-CI server has a fully qualified domain name.
- A dedicated
jenkins
users exists on the node hosting the Jenkins-CI server. - A dedicated account on GitHub exists for the Jenkins bot.
- Centos 7 operating system.
https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions
-
Install the LTS version of Jenkins:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
-
Install Java:
sudo yum remove java
yum install java-1.8.0-openjdk
-
Configure firewall to permit either port 80 or port 8080
-
Check accessibility of the Jenkins-CI server:
http://hostname
orhttp://hostname:8080
-
Acquire adminitrator password:
cat /var/lib/jenkins/secrets/initialAdminPassword
- password may be stored in a different location
https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Ubuntu
- Click on above link.
Navigate to: Manage Jenkins > Manage Plugins
- Cobertura Plugin - for code coverage reporting
- Conditional BuildStep - allows the specification of conditionals during the build step (if not all items of a matrix build should be built)
- GitHub Authentication Plugin - provides a means of using GitHub for authentication and authorization to secure Jenkins
- GitHub Integration Plugin - provides GitHub pull-request and branch triggers
- GitHub Pull Request Builder - build pull-requests from GitHub and report results
Navigate to: Manage Jenkins > Configure Global Security
- Disable remember me [ ✓ ]
- Access Control > Security Realm
- Select
Github Autentication Plugin
- Create a GitHub application registration for Jenkins by accessing:
- Populate fields:
- GitHub Web URI:
https://github.com
- GitHub API URI:
https://api.github.com
- Client ID: {from the above step}
- Client Secret: {from the above step}
- OAuth Scope(s):
read:org,user:email
- GitHub Web URI:
- Select
- Access Control > Authorization
- Select
Matgrix-based security
- Add users and/or groups and set the desired permissions
- Examples:
- GitHub username:
gamess
- GitHub organization:
gms-bbg
- GitHub group in an organization:
gms-bbg*jenkins
- GitHub username:
- Select
- Click on Save
Navigate to: Manage Jenkins > Configure Configure System
- GitHub > GitHub Servers
- Click on the second Advanced... button:
- Click on Manage additional GitHub actions
- Select Convert login and password to token
- The UI will show Convert login and password to token options:
- Select From login and password
- Enter GitHub Login
- Enter GitHub Password
- Click on Create token credentials
- Note the credential ID
- Select From login and password
- Click on Manage additional GitHub actions
- Reload the page proceed
- Click on the second Advanced... button:
- GitHub > GitHub Servers
- Name: {arbitrary name for GitHub server}
- API URL:
https://api.github.com
- Credentials: {select the token you just generated}
- Manage hooks [ ✓ ]
- Click on Save
Navigate to: Manage Jenkins > Configure Configure System
- GitHub Pull Request Builder > GitHub Auth
- GitHub Server API URL:
https://api.github.com
- Credentials: {select auto generated token}*
- Description: {provide an arbitrary name}
- Auto-mange webhooks [ ✓ ]
- Admin list: {supply a GitHub admin username}
- GitHub Server API URL:
- Click on Save
- Give the project a name
- Select Multi-configuration project
- Click on OK
- General:
- [ ✓ ] Discard old builds
- [ ✓ ] GitHub project
- Project url: URL for GitHub project
- Example: https://github.com/gms-bbg/gamess
- Display name: {provude an arbitrary name}
- Project url: URL for GitHub project
- Source Code Management:
- [ ✓ ] Git
- Repositories:
- Repository URL: {provide repository URL used in
git clone
command} - Credentials: {select or add credentials that is able to clone the above repository}
- Click on Advance
- Name:
origin
- Refspec:
+refs/pull/*:refs/remotes/origin/pr/*
- Name:
- Repository URL: {provide repository URL used in
- Branches to build:
- Branch Specifier:
${sha1}
- click on ( ? ) for more information
- Branch Specifier:
- Repositories:
- [ ✓ ] Git
- Build Triggers
- GitHub Branches:
- Trigger Mode:
Hooks with Persisted Data
- Set status before build [ ✓ ]
- Cancel queued builds [ ✓ ]
- Click on Experimental
- Repo providers:
- GitHub Plugin Repository Provider:
- Cache connection? [
- Manage hooks [ ✓ ]
- Repository requested permission:
PULL
- Repo providers:
- Trigger Mode:
- GitHub Pull Request Builder:
- The fields
GitHub API credentials
andAdmin list
will be auto-populated - Use github hooks for build triggering [ ✓ ]
- Click on Advanced..
- Crontab line:
- The Crontab line should be blank
- Crontab line:
- Click on Trigger Setup...
- Click on Add
- Click on Cancel build on update
- Click on Add
- Click on Update commit status during build
- Provide desired values for:
- Commit Status Context
- Commit Status Build Triggered
- Commit Status Build Started
- Provide desired values for:
- Click on Update commit status during build
- Click on Add
- The fields
- GitHub Branches:
- Configuration Matrix
- Define your build matrix
- Build Environment
- [ ✓ ] Delete workspace before build starts
- [ ✓ ] Add timestamps to the Console Output
- Build
- {Launch build script or build commands}
- Click on Save
The following steps will add the use of a "trigger phrase" to initiate a Jenkins-CI build/test.
- Create or configure an existing job that utiltize the GitHub Pull Request Builder
- Build Triggers
- GitHub Pull Request Builder:
- Click on Advanced..
- Trigger phrase: {provide a phrase}
- Only use trigger phrase for build triggering [ ✓ ]
- Click on Advanced..
- GitHub Pull Request Builder:
We will need to create a personal access token on GitHub to give Travis-CI the ability to comment a "trigger phrase" on a pull-request.
- https://github.com/settings/tokens
- Click on Generate new token
- Token description:
Travis-CI Commenter
- Select scopes:
repo
- Full control of private repositories
- Click on Generate token
- Note the personal access token for the next step
We will store the personal access token created in the previous step in an environmental variable that will be accessbile to the Travis-CI worker.
- Access the repository settings on Travis-CI:
- https://travis-ci.com/{username or organization}/{repository name}/settings
- Environmental Variables:
- Click on Add
- Name:
GITHUB_TOKEN
- Value: {personal access token created above}
- Name:
- Click on Add
- Environmental Variables:
- https://travis-ci.com/{username or organization}/{repository name}/settings
Modify the travis.yml
file and add to the after_success:
section:
after_success:
- path/to/shell/script/travis-ci-commenter.sh
Content of travis-ci-commenter.sh :
#!/bin/bash
if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
-d "{\"body\": \"Omaha\"}" \
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"
Replace Omaha with the desired "trigger phrase".