From 7b53fb14795d878f908a78539fb4f11611304977 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 20 Dec 2023 12:02:56 +0100 Subject: [PATCH] Build docker image and push it to registry --- Jenkinsfile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4f0cdfe..5fd62c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,6 +8,10 @@ pipeline { environment { GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER') TWINE_REPO_URL = "https://git.gerhardt.io/api/packages/amarillo/pypi" + REGISTRY_URL = 'git.gerhardt.io' + OWNER = 'amarillo' + IMAGE_NAME = "amarillo" + TAG = 'latest' } stages { stage('Create virtual environment') { @@ -31,7 +35,7 @@ pipeline { echo 'Testing' } } - stage('Build') { + stage('Build package') { steps { echo 'Building package' sh 'python -m build' @@ -42,6 +46,20 @@ pipeline { sh 'python -m twine upload --skip-existing --verbose --repository-url $TWINE_REPO_URL --username $GITEA_CREDS_USR --password $GITEA_CREDS_PSW ./dist/*' } } + stage('Build docker image') { + steps { + echo 'Building image' + docker.build("${OWNER}/${IMAGE_NAME}:${TAG}") + } + } + stage('Push image to container registry') { + steps { + echo 'Pushing image to registry' + docker.withRegistry(REGISTRY_URL, GITEA_CREDS){ + docker.image("${OWNER}/${IMAGE_NAME}:${TAG}").push() + } + } + } } post { always {