pipeline { agent any tools {nodejs "NodeJS"} stages { stage('Prepare') { agent any steps { checkout scm } post { success { echo 'prepare success' } always { echo 'done prepare' } cleanup { echo 'after all other post conditions' } } } stage('build gradle') { steps { sh './gradlew build' sh 'ls -al ./build' } post { success { echo 'gradle build success' } failure { echo 'gradle build failed' } } } stage('dockerizing'){ steps{ sh 'docker build -t cryptoapp:0.1 .' } } stage('Deploy') { steps { sh 'docker ps -q --filter "name=cryptoapp" | grep -q . && docker stop cryptoapp && docker rm cryptoapp | true' sh 'docker run -p 9999:8080 -d --name=cryptoapp cryptoapp:0.1' sh 'docker rmi -f $(docker images -f "dangling=true" -q) || true' } post { success { echo 'success' } failure { echo 'failed' } } } } }