From 94e19bcaadc5acad8e3beb8d7633426a2a3dbaa7 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Tue, 5 Nov 2024 10:28:47 +0100 Subject: [PATCH] ozg-7032 jenkins use withnpm --- Jenkinsfile | 44 ++++++++++---------- Jenkinsfile.admin | 39 +++++++++-------- alfa-client/Jenkinsfile.storybook | 20 ++++----- alfa-client/apps/alfa-e2e/Jenkinsfile | 15 ++++--- alfa-client/apps/alfa-e2e/Jenkinsfile-static | 15 ++++--- 5 files changed, 63 insertions(+), 70 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ab8edc5cc..eb46e2e1ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,27 +53,27 @@ pipeline { script { FAILED_STAGE=env.STAGE_NAME - sh 'npm --version' - sh 'node --version' - dir('alfa-client') { - sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' - sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc' - - sh 'npm cache verify' - sh 'npm install' - - if (isMasterBranch()) { - withSonarQubeEnv('sonarqube-ozg-sh'){ - sh 'npm run ci-sonar' + withNPM(npmrcConfig: 'npm-nexus-auth') { + sh 'npm --version' + sh 'node --version' + + dir('alfa-client') { + sh 'npm cache verify' + sh 'npm install' + + if (isMasterBranch()) { + withSonarQubeEnv('sonarqube-ozg-sh'){ + sh 'npm run ci-sonar' + } + } else { + sh 'npm run ci-test' + } + if (isReleaseBranch()) { + sh 'npm run ci-prodBuild' + } + else { + sh 'npm run ci-build' } - } else { - sh 'npm run ci-test' - } - if (isReleaseBranch()) { - sh 'npm run ci-prodBuild' - } - else { - sh 'npm run ci-build' } } } @@ -92,7 +92,9 @@ pipeline { dir('alfa-client') { IMAGE_TAG = generateImageTag() - sh 'npm run ci-build-alfa-client-container' + withNPM(npmrcConfig: 'npm-nexus-auth') { + sh 'npm run ci-build-alfa-client-container' + } withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { sh 'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}' diff --git a/Jenkinsfile.admin b/Jenkinsfile.admin index 32dd06e291..e361112618 100644 --- a/Jenkinsfile.admin +++ b/Jenkinsfile.admin @@ -35,27 +35,26 @@ pipeline { steps { script { FAILED_STAGE=env.STAGE_NAME - - dir('alfa-client') { - sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' - sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc' - - sh 'npm cache verify' - sh 'npm install' - - if (isReleaseBranch()) { - sh 'npm run ci-prodBuild-admin' - } else { - sh 'npm run ci-build-admin' - } - if (isMasterBranch()) { - withSonarQubeEnv('sonarqube-ozg-sh'){ - sh 'npm run ci-sonar' + + withNPM(npmrcConfig: 'npm-nexus-auth') { + dir('alfa-client') { + sh 'npm cache verify' + sh 'npm install' + + if (isReleaseBranch()) { + sh 'npm run ci-prodBuild-admin' + } else { + sh 'npm run ci-build-admin' + } + if (isMasterBranch()) { + withSonarQubeEnv('sonarqube-ozg-sh'){ + sh 'npm run ci-sonar' + } + } else { + sh 'npm run ci-test' } - } else { - sh 'npm run ci-test' - } - } + } + } } } } diff --git a/alfa-client/Jenkinsfile.storybook b/alfa-client/Jenkinsfile.storybook index b589706023..714fe26bca 100644 --- a/alfa-client/Jenkinsfile.storybook +++ b/alfa-client/Jenkinsfile.storybook @@ -36,20 +36,14 @@ pipeline { steps { script { FAILED_STAGE=env.STAGE_NAME - - dir('alfa-client') { - - withNPM(npmrcConfig: 'a4272a20-bb67-4cf7-8ce5-a1c3ac66613c') { - sh 'npm cache verify' - sh 'npm install' - sh 'npm run ci-storybook' - } - - - - - } + withNPM(npmrcConfig: 'npm-nexus-auth') { + dir('alfa-client') { + sh 'npm cache verify' + sh 'npm install' + sh 'npm run ci-storybook' + } + } } } } diff --git a/alfa-client/apps/alfa-e2e/Jenkinsfile b/alfa-client/apps/alfa-e2e/Jenkinsfile index 4d91927283..22dd8d42af 100644 --- a/alfa-client/apps/alfa-e2e/Jenkinsfile +++ b/alfa-client/apps/alfa-e2e/Jenkinsfile @@ -190,14 +190,13 @@ pipeline { script { FAILED_STAGE = env.STAGE_NAME - sh 'npm --version' - dir('alfa-client') { - sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' - sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc' - - sh 'npm cache verify' - sh 'npm install' - sh "npm run cypress:install" + withNPM(npmrcConfig: 'npm-nexus-auth') { + sh 'npm --version' + dir('alfa-client') { + sh 'npm cache verify' + sh 'npm install' + sh "npm run cypress:install" + } } } } diff --git a/alfa-client/apps/alfa-e2e/Jenkinsfile-static b/alfa-client/apps/alfa-e2e/Jenkinsfile-static index 49a92dd823..01673a5183 100644 --- a/alfa-client/apps/alfa-e2e/Jenkinsfile-static +++ b/alfa-client/apps/alfa-e2e/Jenkinsfile-static @@ -149,14 +149,13 @@ pipeline { script { FAILED_STAGE = env.STAGE_NAME - sh 'npm --version' - dir('alfa-client') { - sh 'echo "registry=https://nexus.ozg-sh.de/repository/npm-proxy" >> ~/.npmrc' - sh 'echo "//nexus.ozg-sh.de/:_auth=amVua2luczprTSFnNVUhMVQzNDZxWQ==" >> ~/.npmrc' - - sh 'npm cache verify' - sh 'npm install' - sh "npm run cypress:install" + withNPM(npmrcConfig: 'npm-nexus-auth') { + sh 'npm --version' + dir('alfa-client') { + sh 'npm cache verify' + sh 'npm install' + sh "npm run cypress:install" + } } } } -- GitLab