Difference between revisions of "Git"

From Lingoport Wiki
Jump to: navigation, search
(Storing the Git Credentials)
(Storing the Git Credentials)
Line 15: Line 15:
   
 
For example,
 
For example,
git config --global credential.helper
+
git config --global credential.helper store
   
 
To test the credentials, execute a <code>git clone</code> (or <code>git pull</code>, etc.) command as the Jenkins Linux user: It will ask you for a username password at the prompt. Once that's entered, re-run a <code>git clone</code> (or <code>git pull</code>, etc.) command: This time, the user should not be prompted for the username password.
 
To test the credentials, execute a <code>git clone</code> (or <code>git pull</code>, etc.) command as the Jenkins Linux user: It will ask you for a username password at the prompt. Once that's entered, re-run a <code>git clone</code> (or <code>git pull</code>, etc.) command: This time, the user should not be prompted for the username password.

Revision as of 16:04, 15 March 2018

Install Git

On the Unix box, install Git. To do so, follow this link: [1]

Git User

A Git user must be provided by the development organization. This Git user must have clone, pull, and push access to the projects' repositories to be on-boarded. This Git user is used for all projects.

Scripts started by the jenkins user clone and push to and from the repository; The Git user login and password must be set as per this page: [2]

Storing the Git Credentials

One possibility is to store the Git credentials on the command line as the Jenkins user that runs the scripts. To do so, please refer to the Git Tools Credentials documentation page.

 The store mode saves the credentials to a plain-text file on disk, and they never expire. This means that until you change your password for the Git host, you won’t ever have to type in your credentials again.

For example,

 git config --global credential.helper store

To test the credentials, execute a git clone (or git pull, etc.) command as the Jenkins Linux user: It will ask you for a username password at the prompt. Once that's entered, re-run a git clone (or git pull, etc.) command: This time, the user should not be prompted for the username password.

SSH

One possibility is to have a user (jenkins on a CI) have an SSH key to be added to the GitHub account for that Linux user. For instance, log in as 'jenkins' on the CI system. Then generate an SSH is it does not already exist, and add the SSH key to the GitHub account. To do so, follow the instructions listed at https://help.github.com/articles/generating-an-ssh-key/ .

.netrc

A possible alternative to the SSH key route is using .netrc.

The following is an example of a ~jenkins/.netrc file on Unix:

  machine github.com
  login gitUserName
  password gitPassword

And on the command line, make sure the following is entered:

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

Test

Make sure you can clone some repository using git clone, without having to enter at the prompt the login and password of the Git user.