Adding Git credentials to Jenkins securely stores authentication details so Jenkins can access Git repositories. It allows Jenkins to clone, pull, or push code during automated build and deployment processes.
Stores credentials like username/password or SSH keys securely in Jenkins
Enables Jenkins to connect with private Git repositories
Used in pipelines and jobs for automated code fetching
Improves security by avoiding hardcoding credentials in scripts
Configuring Jenkins Credentials For Git
Step 1: Open Jenkins Dashboard
Open the Jenkins Dashboard. On the left-hand side of the screen, click on the Manage Jenkins option.
Return to the Jenkins Dashboard and click on Manage Jenkins again. Scroll down to the Security section and click on Credentials (or Manage Credentials).
Step 6: Select Global Domain
In the Credentials screen, look for the Stores scoped to Jenkins section. Click on the (global) domain link located next to the Jenkins store.
Step 7: Add New Credentials
On the Global Credentials page, look at the left-hand menu and click on Add Credentials.
Select Username with password, set scope to Global, and enter Git username, password/PAT, ID (optional), and description.
Kind: Select Username with password. This is the standard and most reliable method for basic repository authentication.
Scope: Select Global. This ensures that the credentials can be accessed by any Jenkins job or pipeline. (Selecting a restricted scope might cause permission errors during your builds).
Username: Enter the username associated with your Git hosting account (e.g., your GitHub username).
Password: Enter your account password or your Personal Access Token (PAT).
ID: You can leave this blank. Jenkins will automatically generate a unique ID string for these credentials. Alternatively, you can type a custom name (like github-creds) to easily identify it in your pipelines.
Description: Enter a clear description, such as "GitHub Login Credentials," so you know exactly what this account is used for.