Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def frontendImage="pandaacademy/frontend"
- def backendImage="pandaacademy/backend"
- def backendDockerTag=""
- def frontendDockerTag=""
- def dockerRegistry=""
- def registryCredentials="dockerhub"
- pipeline {
- agent {
- label 'agent'
- }
- parameters {
- string(name: 'backendDockerTag', defaultValue: '', description: 'Backend docker image tag')
- string(name: 'frontendDockerTag', defaultValue: '', description: 'Frontend docker image tag')
- }
- stages {
- stage('Adjust version') {
- steps {
- script{
- backendDockerTag = params.backendDockerTag.isEmpty() ? "latest" : params.backendDockerTag
- frontendDockerTag = params.frontendDockerTag.isEmpty() ? "latest" : params.frontendDockerTag
- currentBuild.description = "Backend: ${backendDockerTag}, Frontend: ${frontendDockerTag}"
- }
- }
- }
- stage('Clean running containers') {
- steps {
- sh "docker rm -f frontend backend"
- }
- }
- stage('Deploy application') {
- steps {
- script {
- withEnv(["FRONTEND_IMAGE=$frontendImage:$frontendDockerTag",
- "BACKEND_IMAGE=$backendImage:$backendDockerTag"]) {
- docker.withRegistry("$dockerRegistry", "$registryCredentials") {
- sh 'docker-compose up -d'
- }
- }
- }
- }
- }
- }
- post {
- always {
- sh "docker-compose down"
- cleanWs()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement