Update jenkinsfile using credentials

This commit is contained in:
jose-rZM
2025-12-18 11:11:25 +01:00
parent ad5a7798e0
commit 755a5bf2d0

16
Jenkinsfile vendored
View File

@@ -164,7 +164,18 @@ pipeline {
stage('Deploy frontend & backend') {
agent any
environment {
JENKINS_BASE_URL = 'http://jenkins:8080'
JENKINS_JOB_NAME = 'Espetos'
}
steps {
withCredentials([
usernamePassword(
cretentialsId: 'jenkins-api-token',
usernameVariable: 'JENKINS_USER',
passwordVariable: 'JENKINS_TOKEN'
)
]) {
sh '''
set -e
@@ -175,6 +186,10 @@ pipeline {
docker run -d \
--name cafeteria-backend \
-e JENKINS_BASE_URL \
-e JENKINS_JOB_NAME \
-e JENKINS_USER \
-e JENKINS_TOKEN \
-p 8000:8000 \
cafeteria-backend:${BUILD_NUMBER}
@@ -184,6 +199,7 @@ pipeline {
cafeteria-frontend:${BUILD_NUMBER}
'''
}
}
}
}