DevOps Tools/Integration/Jenkins Gitlab

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(Jenkins with Gitlab)
(Configure Jenkins)
Line 38: Line 38:
 
:*API token - paste the access token from gitlab
 
:*API token - paste the access token from gitlab
 
:*Description - you know what to do
 
:*Description - you know what to do
 +
<br>
 +
We need to configure the connection between Jenkins and Gitlab.

Revision as of 16:11, 4 January 2019

Overview | Continuous Integration (CI) | Source Control Management (SCM) | Containerization | Configuration | Integration

Jenkins with Gitlab

Make sure that you have Jenkins and Gitlab installed.

Configure Gitlab

You will need to have at least (1) project setup, though there doesn't need to be anything in it.

  • Log-in to the Gitlab web portal > [click] Projects > [click] New project > give it:
  • Project Name
  • Description
  • Visibility level (i've chosen private)


Next you'll need to add a deploy key, which is found by:

  • [click] on the project name > go to Settings > [click] Repository > [click] Expand next to Deploy Keys > and define the following:
  • Title - pick a easy description that will help identify it as the public ssh key from your jenkins server
  • Key - Paste the public ssh key from your jenkins server.
  • Write access allowed - make sure to check the box to allow.


Finally you will need to create a Jenkins user on Gitlab and then create a API token to provide Jenkins.

  • First create a new user, in this case I called it Jenkins, and then assign them as a maintainer to the previously created project.
  • Next go to the users Settings > [click] Access Tokens > and define:
  • Name - define a name to easily remember what user this is for.
  • Scopes - I opted to just check api

When you create the access token, it will be displayed on the webpage. NOTE: the api key cannot be recovered after you leave this page. Make sure to copy the key and potentially put it somewhere secure, like a keepass database.

Configure Jenkins

First thing we need to do is give Jenkins a copy of the Private SSH key that was created for the jenkins user on the jenkins server.

  • Log-in to the Jenkins web portal > [click] credentials > [click] system > [click] Global credentials > [click] Add credentials

Obviously you can create a domain for a greater level of security instead of using the unrestricted global credentials group

  • Kind - select SSH Username with private key
  • Scope - select the appropriate scope, in my instance i selected global so that all project have access.
  • Username - input the Username of the user created on Gitlab which you obtained an access token from and that has access to the right project
  • Private Key - I only had the option to enter directly as this was the Jenkins Master. Paste the private key you created from the Jenkins user on the Jenkins server.
  • Description - Enter in something that can help you easily identify it in the future.


Now we want to give Jenkins the access token from gitlab.

  • Log-in to the Jenkins web portal > [click] credentials > [click] system > [click] Global credentials > [click] Add credentials
  • Kind - select GitLab API token
  • API token - paste the access token from gitlab
  • Description - you know what to do


We need to configure the connection between Jenkins and Gitlab.

Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
2020 Election
Volkswagen
Covid
NCDMV
Toolbox