From b864818da54fc4e328cd357deff9fb66eb6c2743 Mon Sep 17 00:00:00 2001 From: Alexey Danilevich Date: Tue, 18 Apr 2023 17:09:13 +0300 Subject: [PATCH] Fix UIKit jenkinsfile (#1752) --- deploy/web/Jenkinsfile | 128 ++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 71 deletions(-) diff --git a/deploy/web/Jenkinsfile b/deploy/web/Jenkinsfile index 5cf9dda24..fe662953d 100644 --- a/deploy/web/Jenkinsfile +++ b/deploy/web/Jenkinsfile @@ -6,15 +6,12 @@ G_webbuild = "Not set" G_webdeploy = "Not set" G_statusMergedPR = 'closed' G_developmentBranch = 'development' -G_global_npm_path = "/var/jenkins_home/workspace/Front" +G_global_npm_path = null +G_buildImage = null pipeline { agent { - dockerfile { - dir 'deploy/dockerfiles' - filename 'Dockerfile_Web' - label 'master' - } + label 'linux' } parameters { string(name: 'BRANCH', defaultValue: 'development', description: 'Branch for the build') @@ -48,79 +45,68 @@ pipeline { disableConcurrentBuilds() } stages { + stage('Prepare environment') { + steps { + script { + G_buildImage = "uikit-build-${UUID.randomUUID().toString().toLowerCase()}" + docker.build(G_buildImage, '--no-cache --force-rm -f deploy/dockerfiles/Dockerfile_Web deploy') + } + } + } stage('Check the merge to development') { when { anyOf { environment name: 'FORCE', value: 'true'; allOf {expression { "${action}" == G_statusMergedPR}; expression { "${destination_branch}" == G_developmentBranch}}}} - stages { - stage('Pre-setup') { - steps { - script { - def buildCause = currentBuild.getBuildCauses() - echo "buildCause: ${buildCause}"; - } - } - post { - success { - script{G_setup = "success"} + steps { + script { + docker.image(G_buildImage).inside() { + stage('Pre-setup') { + G_global_npm_path = pwd() + try { + def buildCause = currentBuild.getBuildCauses() + echo "buildCause: ${buildCause}" + G_setup = "success" + } catch(ex) { + G_setup = "failure" + error "Pre-setup failed" + } } - failure { - script{G_setup = "failure"} + stage('Lerna boostrap') { + try { + sshagent (credentials: [G_gitcred]) { + sh """ + npx lerna bootstrap && npx lerna run prepare + """ + } + G_install = "success" + } catch(ex) { + G_install = "failure" + error "Lerna boostrap failed" + } } - } - } - stage('Lerna boostrap') { - steps{ - script { - sshagent (credentials: [G_gitcred]) { + stage('Webapp build'){ + try { sh """ - npx lerna bootstrap && npx lerna run prepare + cd Example + yarn run web:bundle """ + G_webbuild = "success" + } catch(ex) { + G_webbuild = "failure" + error "Lerna boostrap failed" } } - } - post { - success { - script{G_install = "success"} - } - failure { - script{G_install = "failure"} - } - } - } - stage('Webapp build'){ - steps { - script { - sh """ - cd Example - yarn run web:bundle - """ - } - } - post { - success { - script{G_webbuild = "success"} - } - failure { - script{G_webbuild = "failure"} - } - } - } - stage('Webapp deploy'){ - steps { - script { - sh """ - npm config set prefix $G_global_npm_path - alias firebase="`npm config get prefix`/bin/firebase" - cd Example - firebase deploy --token "$token" - """ - } - } - post { - success { - script{G_webdeploy = "success"} - } - failure { - script{G_webdeploy = "failure"} + stage('Webapp deploy'){ + try { + sh """ + npm config set prefix $G_global_npm_path + alias firebase="`npm config get prefix`/bin/firebase" + cd Example + firebase deploy --token "$token" + """ + G_webdeploy = "success" + } catch(ex) { + G_webdeploy = "failure" + error "Webapp deploy failed" + } } } }