Jenkins will need the docker hub credentials to build and push the image to the dockerHub. Instead of using dockerHub username and password, we will Create an Access Token in the dockerHub.
- Log in to DockerHub
- Click on the profile Icon and click on the Account settings
3. Click on the Security tab on the left menu, click on the "New Access Token and Enter a brief Description. After clicking "Generate" button, click on the "Copy and Close" button.
On Jenkins navigate to add a global credential
Enter the details needed to create the credential and save
if you don't have a project you can clone this https://github.com/Ericawanja/Jenkins-DockerHub-Automation
Delete the Jenkinsfile and Dockerfile to follow along
Let's start with creating a Jenkinsfile