Storing Passwords in Jenkins—Here’s How I Keep Them Safe and Sound!

First, create a Personal Access Token. How do you create a PAT?

  • Follow These Steps:
  1. Log in to DockerHub: https://hub.docker.com/

  2. Go to Account settings:

  1. Click on Generate New Token:

  1. Add the following details:

  1. Once you click on Generate, you will see your Docker username and password details encrypted.

    Note: We use this method because it is a safe way to log in. Otherwise, you could use the docker login -u 'username' -p 'password' command, but it is not recommended due to security concerns.

  2. Go to Jenkins Dashboard → Manage Jenkins → Security → Credentials(global) [Add cred in (global) domain]

  1. Click on Add Credentials:

  1. Add required details:

This is how you can store passwords in Jenkins.

Now you can access your image in any docker repository.

  • You can also store GitHub credentials in Jenkins in a similar way to DockerHub, allowing you to access any private repository.

I hope you understand the concept of storing password in Jenkins.

Happy Learning! :)

0
Subscribe to my newsletter

Read articles from Chetan Mohanrao Mohod directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Chetan Mohanrao Mohod
Chetan Mohanrao Mohod

DevOps Engineer focused on automating workflows, optimizing infrastructure, and building scalable efficient solutions.