diff --git a/Jenkinsfile_CD b/Jenkinsfile_CD index 07e1a36..1634fd5 100644 --- a/Jenkinsfile_CD +++ b/Jenkinsfile_CD @@ -17,6 +17,11 @@ pipeline { } stages { + stage('Init container') { + steps { + sh 'apt-get update && apt-get install -y sshpass openssh-client' + } + } stage('Build') { steps { sh 'mvn -B -DskipTests -X clean package spring-boot:repackage' @@ -25,9 +30,6 @@ pipeline { stage('Deploy') { steps { script { - - sh 'apt-get update && apt-get install -y sshpass openssh-client' - sh """ sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'mkdir -p ${PATH_TO_DEV_FOLDER}' sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} target/*.jar ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/ @@ -39,6 +41,11 @@ pipeline { } } } + stage('Prune images') { + steps { + sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image prune -f' + } + } } } diff --git a/Jenkinsfile_CI b/Jenkinsfile_CI index 5cf3091..29b9fcc 100644 --- a/Jenkinsfile_CI +++ b/Jenkinsfile_CI @@ -12,4 +12,9 @@ pipeline { } } } + stage('Prune images') { + steps { + sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image prune -f' + } + } } \ No newline at end of file