Skip to Content
This document is part of a series of documents covering Continuous Integration setup for a UI5 application.
  1. Setting up Jenkins with GitHub                                                   ( You are currently here )
  2. Setting up Jenkins with GitHub (on Linux – Ubuntu 14.04)
  3. Configuring Jenkins to run Unit tests and Lint checks
  4. Configuring Jenkins to run Build Automatically on Code Push

In a typical software development model, there are multiples programmers contributing to the same codebase. This causes many bugs in the codebase, which significantly slows down development.

Continuous Integration is a practice that involves developers checking-in their code several times a day to a central code repository. Each time code is checked in, automated builds and tests run. Since this happens several times a day, problems are detected early and they are resolved before development continues further. This practice requires: a Continuous Integration server which runs the automated builds and tests; a version control system that tracks changes in the codebase.

In this setup, we will use:

  • Jenkins: an open-source continuous integration server.
  • Git: a Version Control System
  • GitHub: to host the code repository online, so that multiple developers can access it over the internet. GitHub is a web-based Git repository hosting service that can be used free of cost.

19-Nov-15 9-54-18 PM.jpg

Figure 1: Continuous Integration setup with Jenkins

In this article, we shall cover the section shown in orange. This focuses on the steps required to enable Jenkins to communicate with GitHub.

There are several ways of connecting Jenkins to a remote repository on GitHub (SSH, HTTPS, Subversion). In this tutorial, we use SSH authentication, as this eliminates the need to enter your username and password every time you run a Git command. Also, this eliminates the need for a local issuer certificate (SSL) on Jenkins.


1. Prerequisites

    • GitHub (github.wdf.sap.corp) account is set up with a repository.
    • Git for Windows is set up on your computer, using SSH for authentication. (A tutorial on this is available here.)
    • Jenkins is installed on your computer [with Git plugin installed].

2. Configuring Jenkins for Git


Open your Jenkins Dashboard.

Go to: Manage Jenkins > Configure System

Under ‘Git’, add a new Git installation with the ‘Path to Git executable’ set to: C:\Program Files\Git\cmd\git.exe

1.GitPath.jpg

NOTE: It is necessary to use this particular git.exe file. There will be multiple git.exe files in other folders. However, pointing Jenkins to any other git.exe file will give you a humongous stack trace of an exception beginning with: ssh executable not found.


3. Running Jenkins as a service of your user account

Open Task Manager > Services > Open Services

Select ‘Jenkins’ from the list > Right-click > Properties

2.JenkinsProcess.jpg

Go to the “Logon” tab

Select ‘This account’, and enter your local account name and password (including domain details, if required).

3.JenkinsProperties.jpg

Restart Jenkins to allow the changes to take effect.

4. Setting up Credentials in Jenkins


Open the Jenkins dashboard.

Go to: Credentials > Global credentials > Add Credentials

4.JenkinsCredentials.jpg

The ‘Kind’ and ‘Scope’ will be as shown above.

For the Username, enter your GitHub username.

Select ‘From the Jenkins master ~/.ssh’ for the Private Key.

Enter the passphrase that you used while setting up SSH. Leave it blank if you didn’t use any passphrase.

5. Setting up a project in Jenkins

New Item > Free Style project

For ‘GitHub project’, enter the URL of the repository on GitHub.

Under ‘Source Code Management’, select ‘Git’.

Enter the URL of the repository in SSH format.

Select credentials that you set up in step 4.

Save.

TABLE OF POSSIBLE ERRORS

ERROR PROBABLE CAUSE SOLUTION

javax.servlet.ServletException: java.lang.RuntimeException: ssh executable not found. The git plugin only supports official git client http://git-scm.com/download/win

In your Jenkins global configuration, the Path to Git Executable is not pointing to the git.exe provided by the official Git for Windows client. In your Jenkins server, go to Manage Jenkins > Configure System and set ‘Path to Git Executable’ to C:\Program Files\Git\cmd\git.exe
Failed to connect to repository : Command “C:\Program Files\Git\cmd\git.exe -c core.askpass=true ls-remote -h git@github.wdf.sap.corp:I322118/FBA_StandardTiles.git HEAD” returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Jenkins is running as a service on the local user account instead of your account. Follow Step 3 to run Jenkins as a service on your user account.

Failed to connect to repository : Command “C:\Program Files\Git\cmd\git.exe -c core.askpass=true ls-remote -h https://github.wdf.sap.corp/I322118/FBA_StandardTiles.git HEAD” returned status code 128:

You are using an HTTPS URL to your GitHub repo instead of an SSH URL.

Go to your GitHub repo, and click on ‘SSH’ and copy that URL. It should be in the following format:

  git@github.wdf.sap.corp:<username>/repo_name.git

You should now be able to execute a build and see it pass, if Jenkins successfully fetches your code from GitHub. The next step is to set up builds and tests that run on the code that you push to GitHub.

In the next article, we will talk about Test-Driven Development in UI5 applications, and the various tools available to this end. This will help us set up ‘Unit tests’ shown in the ‘NodeJS Plugin’ section in Figure 1.

This article was written with the contribution of :  MOUNIKA GANTA

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply