Configuring Jenkins' credentials

To allow Jenkins to access your project source files, you must create an SSH key pair and add the public key to the GitHub account that is hosting your repository (in the same way that you did for each team member's computer). You then configure Jenkins to use the private key in this pair to authenticate when connecting to the server. Jenkins connects to the server to clone a local copy of the repository and update it with the latest changes prior to each automated build.

To configure Jenkins' credentials

  1. If you haven't already, create an SSH key pair and add the public key to the GitHub account that is hosting your repository.
  2. In a browser, navigate to your Jenkins dashboard (for example, http://localhost:8080, if working on the Jenkins host computer).
  3. In the sidebar menu, click Manage Jenkins.
  4. In the Security section, click Manage Credentials.
  5. In the Stores scoped to Jenkins section, click the Jenkins store.
  6. In the Global credentials (unrestricted) list, click Add credentials.
  7. In the Kind list, select SSH Username with private key.
  8. In the ID box, substitute in the name of your project and enter MyProjectGitHubJenkinsCredentials.
  9. In the Username box, enter the email address associated with your GitHub account.
  10. In a text editor, open the private key file of the SSH key pair that you generated for Jenkins to connect to the GitHub repository (that is, the ~/.ssh/id_ed25519 file).
  11. Copy the full contents of the file, and then close the editor.
  12. In the Private Key section of the Jenkins build configuration, in the Key box, click Add.
  13. In the Key box, paste the contents of the private key file.
  14. In the Passphrase box, enter the passphrase that you defined when creating this key.
  15. Click OK to close the pane.

Now that you have provided the credentials Jenkins needs to access your repository, you are ready to configure a scheduled build for your project.