Create a Jenkins Job
Creating a Jenkins job for your Gitlab project can be broken into 3 major steps:
- Create Jenkins Job
- Configure Gitlab Project
- Add Status Badge to Project
Create Jenkins Job
- Go to http://ci.digitec.local
- Click New Job in the left sidebar
- Put your (Gitlab) project name as the job name - e.g.
kd-ui
- Choose Build a free-style software project
- Click OK button
- Configure Source Code Management
- Select Git
- Enter your repository URL - e.g.
git@vc.digitec.local:kd/kd-ui.git
-
Credentials:
jenkins
-
Repository browser:
gitlab
- Then enter your Gitlab URL - e.g.
https://vc.digitec.local/kd/kd-ui/
- Grab the Gitlab version from Gitlab Admin Area and enter it in the Version text input - e.g.
6.4.3
- Under Build Triggers, enable Poll SCM
- Configure the Build section. This varies per project. The following is the build for the
kd-ui
project- From Add Build Step dropdown, chhose Execute Shell
-
Commands:
npm install
grunt jenkins
- Under Post-build Actions, choose E-mail Notification from the dropdown
- Enable both checkboxes, and make any other modifications you see fit
- Click Save button
- Click Build Now from the sidebar on the left to confirm that your build runs successfully
Configure Gitlab Project
- Go to the Settings section of your Gitlab project - e.g.
https://vc.digitec.local/kd/kd-ui-docs/edit
- Choose the Web Hooks link from the left sidebar
- Enter
http://ci.digitec.local/git/notifyCommit?url={GIT PROJECT SSH URL}
, where{GIT PROJECT SSH URL}
is the SSH URL for your Gitlab project - e.g.git@vc.digitec.local:kd/kd-ui.git
- Enable the Push events trigger, and click Add Web Hook
- The Test Hook functionality doesn't appear to be working at the time of this writing, push a change to your Gitlab repository and then check your Jenkins job to verify that it was triggered.
Add Status Badge to Project
Add a Jenkins status badge to your project's README.md
file, beneath the title, in the following format
[![Jenkins]({JENKINS JOB URL}/badge/icon)]({JENKINS JOB URL})
Where {JENKINS JOB URL}
is the URL to your Jenkins job - e.g:
[![Jenkins](http://ci.digitec.local/job/kd-ui/badge/icon)](http://ci.digitec.local/job/kd-ui/)