Add Jenkins pipeline for building and pushing Docker images for yoga app
This commit is contained in:
parent
aba6d023d0
commit
0b0f370c3b
70
environment/infra/jenkins/build.app.image.Jenkinsfile
Normal file
70
environment/infra/jenkins/build.app.image.Jenkinsfile
Normal file
@ -0,0 +1,70 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
DOCKER_IMAGE = 'yoga-app'
|
||||
DOCKER_REGISTRY = 'docker.rschneider.hu/infra'
|
||||
DOCKER_CREDENTIALS_ID = 'your-docker-credentials-id'
|
||||
CURRENT_VERSION = ''
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: 'main', credentialsId: 'rschneider_gitea.rschneider.hu', poll: false, url: 'https://gitea.rschneider.hu/rschneider/yogastic.git'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Build Docker image') {
|
||||
steps {
|
||||
sh """
|
||||
cd environment/dev/docker/app/scripts
|
||||
bash ./build.docker.build.sh
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Commit & Push version image') {
|
||||
steps {
|
||||
script {
|
||||
CURRENT_VERSION = readFile('environment/dev/docker/app/scripts/version.txt').trim()
|
||||
env.CURRENT_VERSION = CURRENT_VERSION
|
||||
}
|
||||
withCredentials([
|
||||
gitUsernamePassword(credentialsId: 'rschneider_gitea.rschneider.hu', gitToolName: 'Default')
|
||||
]) {
|
||||
sh """
|
||||
cd environment/dev/docker/app/scripts
|
||||
git config user.email "jenkins@rschneider.hu"
|
||||
git config user.name "Jenkins"
|
||||
git status
|
||||
git add version.txt
|
||||
git commit -m "[ci-skip] Update version to ${CURRENT_VERSION}"
|
||||
git push --set-upstream origin main
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Docker image') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'rschneider-docker-reop1', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
|
||||
sh """
|
||||
echo $PASSWORD | docker login -u $USERNAME --password-stdin ${DOCKER_REGISTRY}
|
||||
cd environment/dev/docker/app/scripts
|
||||
|
||||
bash ./build.docker.push.sh
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user