node { checkout scm docker_tag = 'latest' projectname ='app' packagejson = readJSON file: 'package.json' docker_tag = packagejson['version'] projectname = packagejson['name'] } pipeline { agent any options { timestamps() buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10') ansiColor('xterm') } stages { stage('Check') { steps { echo 'Checking..' sh label: '', script: 'docker --version' //sh "printenv | sort" } } stage('Docker build') { steps { echo 'Docker build....' sh label: '', script: 'docker build -f ./docker/Dockerfile --build-arg docker_registry=dhub.lex.lan:5000 -t dhub.lex.lan:5001/app/'+projectname+':'+docker_tag+' --no-cache .' } } stage('docker push'){ steps { script { docker.withRegistry('http://dhub.lex.lan:5001/', '6173afa3-27b0-4357-8b97-9d1ee071784c') { docker.image("dhub.lex.lan:5001/app/"+projectname+":${docker_tag}").push() } } } } stage('docker cleanup'){ steps { sh label: '', script: 'docker rmi dhub.lex.lan:5001/app/'+projectname+':'+docker_tag } } } }