From f484779fa4f0bd8968f47fb034ac7bffef1a138d Mon Sep 17 00:00:00 2001 From: Sebastian Seedorf Date: Mon, 19 Apr 2021 10:41:01 +0200 Subject: [PATCH] Added Jenkinsfile 6 --- Jenkinsfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2d1bb39..28a1777 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,12 +22,20 @@ THE SOFTWARE. node { + sh 'git name-rev --name-only HEAD > GIT_BRANCH' + sh 'cat GIT_BRANCH' + git_branch = readFile('GIT_BRANCH').trim().substring(0, 10) + env.GIT_BRANCH = git_branch + sh 'rm GIT_BRANCH' + env.NODEJS_HOME = "${tool 'node14'}" env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}" + env.DOCKER_NAME="web/wannistesvorbei:${env.BRANCH_NAME}-${env.GIT_COMMIT}" + def customImage - currentBuild.result = "UNSTABLE" + currentBuild.result = "SUCCESS" try { @@ -51,7 +59,7 @@ node { stage('Build Docker'){ - customImage = docker.build("web/wannistesvorbei:${env.BRANCH_NAME}-${env.GIT_COMMIT}") + customImage = docker.build(env.DOCKER_NAME) } stage('Deploy'){ @@ -70,8 +78,6 @@ node { stage('Cleanup'){ - currentBuild.result = "SUCCESS" - echo 'prune and cleanup' sh 'npm prune' sh 'rm node_modules -rf'