Member-only story
Jenkins Pipeline Push Docker Images to Docker Hub — Learning Jenkins
2 min readAug 18, 2023
INTRODUCTION
In the two previous articles, we successfully pushed Docker images to Docker Hub and integrated Jenkins pipeline with SonarQube + Node.js & GitLab. In this article, we will do both. This is usually part of the CI/CD process.
SETUP JENKINS
Add Docker Hub credentials to the Jenkins environment.
CREATE JENKINS PIPELINE
Step 1: Create a Pipeline Script
pipeline{
environment {
registry = "arramsyah/docker-rest-api-app"
registryCredential = 'cf0e37c1-bb1f-4cee-a617-561868f13486'
dockerImage = ''
}
agent any
stages {
stage ("Code Clone From Gitlab") {
steps {
git branch: 'main',
credentialsId: '9d83a27b-a8d9-4db7-b3c1-b88f5d6f9628',
url: 'https://github.com/izzatarramsyah/nodejs-sample-api.git'
}
}
stage("Sonarqube Analysis") {
environment {
SCANNER_HOME = tool 'sonarqube' // sonar-scanner is the name of the tool in the manage jenkins> tool configuration
}
steps {
withSonarQubeEnv(installationName: 'sonarqube') { //installationName is the name of sonar installation in manage jenkins>configure system
bat "%SCANNER_HOME%/bin/sonar-scanner \…