Update Push to Registry stage with secure credentials handling for DigitalOcean
Some checks failed
DevSecOps-Multibranch/pipeline/head There was a failure building this commit

This commit is contained in:
2025-11-30 15:47:18 +05:30
parent e934074647
commit 266b9b59c2

19
Jenkinsfile vendored
View File

@@ -42,10 +42,21 @@ pipeline {
stage('Push to Registry') { stage('Push to Registry') {
steps { steps {
script { // Securely inject the token into the script
echo "Pushing images to DigitalOcean..." withCredentials([string(credentialsId: 'do-registry-token', variable: 'DO_TOKEN')]) {
sh "docker push ${REGISTRY_URL}/${REPO_NAME}:${BACKEND_TAG}" script {
sh "docker push ${REGISTRY_URL}/${REPO_NAME}:${FRONTEND_TAG}" echo "Logging into DigitalOcean Registry..."
// Explicit Login: Uses the token as both user and password (DO Standard)
sh 'echo $DO_TOKEN | docker login registry.digitalocean.com -u $DO_TOKEN --password-stdin'
echo "Pushing images..."
sh "docker push ${REGISTRY_URL}/${REPO_NAME}:${BACKEND_TAG}"
sh "docker push ${REGISTRY_URL}/${REPO_NAME}:${FRONTEND_TAG}"
// Cleanup: Logout to keep the agent secure
sh 'docker logout registry.digitalocean.com'
}
} }
} }
} }