pipeline { agent { label 'server_61' } stages { stage('Checkout') { steps { checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: '[email protected]:github.git/']]) } } stage('Down Docker') { steps { script { sh 'docker-compose down' } } } stage('Remove Image') { steps { script { // Check if the Docker image exists and remove it if it does sh 'docker image ls dashboardpkt_app:latest | grep dashboardpkt_app && docker image rm dockrimg:latest || echo "Image not found, skipping removal"' } } } stage('Remove Volume') { steps { script { // Check if the Docker volume exists and remove it if it does sh 'docker volume ls | grep dashboardpkt_build-app && docker volume rm dockervolume || echo "Volume not found, skipping removal"' } } } stage('Build and Run Docker Compose') { steps { script { sh 'docker-compose up --build -d' } } } } }
Tambahan tips kalau jekins tidak bisa jalan karena masalah ssl error
jalankan command ini di vm jenkins
ssh-keyscan github.com >> ~/.ssh/known_hosts
Discover more from Susiloharjo
Subscribe to get the latest posts sent to your email.