Skip to main content

GitLab and Jenkins configuration through SSH

In my previous post I have mentioned how to integrate GitLab with Jenkins using username and password. Now we will learn how to configure Jenkins and GitLab using SSH connection.
  • Login as Jenkins user
sudo su - jenkins
  • Run the following command to generate SSH key, 
ssh-keygen
  • Now it will create  a directory named .ssh if it doesn't exist, Press enter and re-enter when you are prompted to enter passphrase.
thuvvareka:~ jenkins$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/Shared/Jenkins/.ssh/id_rsa): 
Created directory '/Users/Shared/Jenkins/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/Shared/Jenkins/.ssh/id_rsa.
Your public key has been saved in /Users/Shared/Jenkins/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:O9APiAETUYC87e9T6k18SPFQxEN4R2gJbKG6JLOID64 jenkins@thuvvareka.local
The key's randomart image is:
+---[RSA 2048]----+
|..*=. .oB++.     |
|.. o  .+.B .     |
|  o ...oo o      |
| . ..o o+        |
| o.o. o.S.       |
|o =.. oo.+       |
|+. .. o+o..      |
|.o   +o ..       |
|E.. oo..         |
+----[SHA256]-----+
  • You can view a key pair in directory .ssh
thuvvareka:.ssh jenkins$ ls -la
total 16
drwx------   4 jenkins  jenkins   128 Apr 10 15:00 .
drwxr-xr-x  10 jenkins  jenkins   320 Apr 10 15:00 ..
-rw-------   1 jenkins  jenkins  1831 Apr 10 15:00 id_rsa
-rw-r--r--   1 jenkins  jenkins   406 Apr 10 15:00 id_rsa.pub
  • Copy id_rsa.pub content in GitLab SSH keys
  • Copy id_rsa content in Jenkins credentials
Jenkins -> Credentials -> System -> Global Credentials -> Add Credentials


Now your SSH connection between GitLab and Jenkins has been successfully established.

Comments

Popular posts from this blog

Mobile Test Automation using Appium and Android studio

In this article we will discuss about how to automate Mobile application using Appium Server and Android Studio. Appium supports both iOS and Android. Appium is HTTP server. It receives the commands from client, executes the command on Mobile device and send a HTTP response representing the result of the command execution. I am going to use Android studio to create a virtual emulator. And Selenium WebDriver will be used to write the Client. I would prefer to use the virtual emulator instead of using real device. In actual devices you may find difficulties to connect/detect it. Pre-requisites .apk file is required to install in Mobile device (Virtual emulator). Android Studio, Appium desktop server and intelliJ IDEA have to be installed. Virtual emulator This post guides you to create the Virtual emulator using Android Studio. Once you launch the emulator now It's time to install the mobile application which is going to be automated. Drag and drop the apk file ...

Data Driven Protractor Testing

In this article I would like to share knowledge regarding Data driven testing. When using a Data driven automation test framework, we do not need to hard code the test data. Instead it enables to access the test data from a separate data file and use them in the automated test cases. First, let's take a look at a simple Protractor script without Data Driven framework describe('Angular home page', function () {       it('should add the String in todo list ', function () {          browser.get('https://angularjs.org/');          element.all(by.css("[placeholder='add new todo here']")).sendKeys("Add POM");          element(by.css('input.btn-primary')).click();          var getText = element.all(by.css('label.checkbox'));          getText.get(2).getText().then(function (results) {          expect(results).toEqua...