Raplce implicit docker calls with shared library steps
This commit is contained in:
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@@ -1,3 +1,5 @@
|
||||
@Library('example-shared-lib@main') _
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
label "docker-agent-dsrv02"
|
||||
@@ -54,23 +56,21 @@ pipeline {
|
||||
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
echo "Building Docker image..."
|
||||
sh "docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID} -f deployments/docker/Dockerfile deployments/docker/"
|
||||
dockerBuild(
|
||||
imageName: "${IMAGE_TAG}",
|
||||
dockerfile: "deployments/docker/Dockerfile",
|
||||
context: "deployments/docker"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Docker Image') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'postio-bot-gitea', // <-- Update to your Jenkins credentials ID
|
||||
usernameVariable: 'DOCKER_USER',
|
||||
passwordVariable: 'DOCKER_PASS'
|
||||
)]) {
|
||||
echo "Logging into Docker registry..."
|
||||
sh "echo $DOCKER_PASS | docker login ${DOCKER_REGISTRY} -u $DOCKER_USER --password-stdin"
|
||||
echo "Pushing Docker image..."
|
||||
sh "docker push ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID}"
|
||||
}
|
||||
dockerPush(
|
||||
imageName: "${IMAGE_TAG}",
|
||||
registry: "${DOCKER_REGISTRY}",
|
||||
credentialsId: "postio-bot-gitea"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user