From 71c1e3596942491cf1daf54af27bc439c20b39c5 Mon Sep 17 00:00:00 2001 From: r_minaeva Date: Tue, 25 Oct 2022 10:14:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20Jenkinsfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..921c999 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,52 @@ +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+' .' + } + } + 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 + } + } + } +} \ No newline at end of file