Home / Jenkins / Create Job
Create a Jenkins Job
Creating a Jenkins job for your Gitlab project can be broken into 3 major steps:
- Configure New Jenkins Job
- Configure Gitlab Project
- Add Status Badge to Project
KD / kd-ui project as an example
For the workflow below, we will reference theConfigure New Jenkins Job
- Go to http://ci.digitec.local
- Click New Item in the left sidebar
- Put your (Gitlab) project name as the item 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 the major.minor version in the Version text input - e.g.
6.6
-
IMPORTANT - At the time of this writing, if you place a
patch
number in your version, Jenkins will throw an error. So, if the Gitlab version is6.6.5
, you should enter6.6
into the Jenkins text input.
-
IMPORTANT - At the time of this writing, if you place a
- 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, choose 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
You will need to make sure that the Jenkins user has access to the 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
Use the Jenkins Status Badge Example snippet to add a Jenkins status badge to your project's README.md
file.