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 {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
label "docker-agent-dsrv02"
|
label "docker-agent-dsrv02"
|
||||||
@@ -54,23 +56,21 @@ pipeline {
|
|||||||
|
|
||||||
stage('Build Docker Image') {
|
stage('Build Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
echo "Building Docker image..."
|
dockerBuild(
|
||||||
sh "docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID} -f deployments/docker/Dockerfile deployments/docker/"
|
imageName: "${IMAGE_TAG}",
|
||||||
|
dockerfile: "deployments/docker/Dockerfile",
|
||||||
|
context: "deployments/docker"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Push Docker Image') {
|
stage('Push Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(
|
dockerPush(
|
||||||
credentialsId: 'postio-bot-gitea', // <-- Update to your Jenkins credentials ID
|
imageName: "${IMAGE_TAG}",
|
||||||
usernameVariable: 'DOCKER_USER',
|
registry: "${DOCKER_REGISTRY}",
|
||||||
passwordVariable: 'DOCKER_PASS'
|
credentialsId: "postio-bot-gitea"
|
||||||
)]) {
|
)
|
||||||
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}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user