From e67fe760a06f682465a2b4b93711e147d86c99e9 Mon Sep 17 00:00:00 2001 From: Nidhi Bansal Date: Mon, 23 Apr 2018 14:44:34 +0530 Subject: [PATCH] renaming varibales to meaningful names in groovy scripts and code reorgnaisation. --- ...gitEmail.groovy => gitNotification.groovy} | 2 +- ...il.groovy => jobStatusNotification.groovy} | 2 +- src/com/devopsnext/devops/maven/build.groovy | 69 --------- .../devops/maven/mavenOperations.groovy | 141 ++++++++++++++++++ .../devopsnext/devops/maven/publish.groovy | 40 ----- src/com/devopsnext/devops/maven/test.groovy | 65 -------- src/com/devopsnext/devops/npm/build.groovy | 41 ----- .../devops/npm/npmOperations.groovy | 135 +++++++++++++++++ src/com/devopsnext/devops/npm/publish.groovy | 70 --------- src/com/devopsnext/devops/npm/test.groovy | 40 ----- .../{analysis.groovy => mvnSonarOp.groovy} | 8 +- .../{analysis.groovy => npmSonarOp.groovy} | 3 + vars/Git.groovy | 6 +- vars/maven_Build.groovy | 6 +- vars/maven_Publish.groovy | 4 +- vars/maven_SonarAnalysis.groovy | 6 +- vars/maven_Test.groovy | 4 +- vars/notify.groovy | 6 +- vars/npm_Build.groovy | 8 +- vars/npm_Publish.groovy | 6 +- vars/npm_SonarAnalysis.groovy | 12 +- vars/npm_Test.groovy | 8 +- 22 files changed, 320 insertions(+), 362 deletions(-) rename src/com/devopsnext/devops/email/{gitEmail.groovy => gitNotification.groovy} (96%) rename src/com/devopsnext/devops/email/{sendmail.groovy => jobStatusNotification.groovy} (98%) delete mode 100644 src/com/devopsnext/devops/maven/build.groovy create mode 100644 src/com/devopsnext/devops/maven/mavenOperations.groovy delete mode 100644 src/com/devopsnext/devops/maven/publish.groovy delete mode 100644 src/com/devopsnext/devops/maven/test.groovy delete mode 100644 src/com/devopsnext/devops/npm/build.groovy create mode 100644 src/com/devopsnext/devops/npm/npmOperations.groovy delete mode 100644 src/com/devopsnext/devops/npm/publish.groovy delete mode 100644 src/com/devopsnext/devops/npm/test.groovy rename src/com/devopsnext/devops/sonar/maven/{analysis.groovy => mvnSonarOp.groovy} (96%) rename src/com/devopsnext/devops/sonar/npm/{analysis.groovy => npmSonarOp.groovy} (95%) diff --git a/src/com/devopsnext/devops/email/gitEmail.groovy b/src/com/devopsnext/devops/email/gitNotification.groovy similarity index 96% rename from src/com/devopsnext/devops/email/gitEmail.groovy rename to src/com/devopsnext/devops/email/gitNotification.groovy index 145ef44..221600b 100644 --- a/src/com/devopsnext/devops/email/gitEmail.groovy +++ b/src/com/devopsnext/devops/email/gitNotification.groovy @@ -1,7 +1,7 @@ #!groovy package com.devopsnext.devops.email -def gitSendmail(String to, String from, String subject, String body) +def gitSendEmail(String to, String from, String subject, String body) { try { String currentResult = 'SUCCESS' diff --git a/src/com/devopsnext/devops/email/sendmail.groovy b/src/com/devopsnext/devops/email/jobStatusNotification.groovy similarity index 98% rename from src/com/devopsnext/devops/email/sendmail.groovy rename to src/com/devopsnext/devops/email/jobStatusNotification.groovy index b9ad7bd..715c270 100644 --- a/src/com/devopsnext/devops/email/sendmail.groovy +++ b/src/com/devopsnext/devops/email/jobStatusNotification.groovy @@ -1,7 +1,7 @@ #!groovy package com.devopsnext.devops.email -def sendmail(String to) +def sendEmail(String to) { try { String currentResult = 'SUCCESS' diff --git a/src/com/devopsnext/devops/maven/build.groovy b/src/com/devopsnext/devops/maven/build.groovy deleted file mode 100644 index 598582b..0000000 --- a/src/com/devopsnext/devops/maven/build.groovy +++ /dev/null @@ -1,69 +0,0 @@ -#!groovy -package com.devopsnext.devops.maven - -String MAVEN_GOALS,MAVEN_ROOT_POM - -/************************************* -** Function to set the variables. -**************************************/ -void setValue(String maven_goals,String root_pom) -{ - this.MAVEN_GOALS = maven_goals - this.MAVEN_ROOT_POM = root_pom -} - -/************************************* -** Function to compile the code. -**************************************/ -def compile() -{ - try { - if ( "${MAVEN_ROOT_POM}" == "null" ) { - MAVEN_ROOT_POM = "pom.xml" - } - if ( "${MAVEN_GOALS}" == "null" ) { - MAVEN_GOALS = "clean install" - } - if (fileExists("${MAVEN_ROOT_POM}")) - { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] compiling code from pom ${MAVEN_ROOT_POM}, please wait..." - println "\u001B[32mPOM VERSION => " + getVersion() - sh "mvn -f ${MAVEN_ROOT_POM} -B ${MAVEN_GOALS} -Dmaven.test.skip=true" - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - else - { - wrap([$class: 'AnsiColorBuildWrapper']) { - error "\u001B[41m[ERROR] ${MAVEN_ROOT_POM} file does not exist..." - } - } - } - catch (Exception excp) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to compile code using ${MAVEN_ROOT_POM}..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw excp - } - } -} -/******************************************** -** Function to get the version from POM -*********************************************/ -def getVersion() -{ - try { - def matcher = readFile("${MAVEN_ROOT_POM}") =~ '(.+)-.*' - matcher ? matcher[0][1] : null - } - catch (Exception error) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to get version from ${MAVEN_ROOT_POM}..." - throw error - } - } -} - diff --git a/src/com/devopsnext/devops/maven/mavenOperations.groovy b/src/com/devopsnext/devops/maven/mavenOperations.groovy new file mode 100644 index 0000000..da915d5 --- /dev/null +++ b/src/com/devopsnext/devops/maven/mavenOperations.groovy @@ -0,0 +1,141 @@ +#!groovy +package com.devopsnext.devops.maven + +String MAVEN_GOALS,MAVEN_ROOT_POM + +/************************************* +** Function to set the variables. +**************************************/ +void setValues(String maven_goals,String root_pom) +{ + this.MAVEN_GOALS = maven_goals + this.MAVEN_ROOT_POM = root_pom +} + +/************************************* +** Function to set the pom variable. +**************************************/ +void setValue(String root_pom) +{ + this.MAVEN_ROOT_POM = root_pom +} +/************************************* +** Function to compile the code. +**************************************/ +def compile() +{ + try { + if ( "${MAVEN_ROOT_POM}" == "null" ) { + MAVEN_ROOT_POM = "pom.xml" + } + if ( "${MAVEN_GOALS}" == "null" ) { + MAVEN_GOALS = "clean install" + } + if (fileExists("${MAVEN_ROOT_POM}")) + { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] compiling code from pom ${MAVEN_ROOT_POM}, please wait..." + println "\u001B[32mPOM VERSION => " + getVersion() + sh "mvn -f ${MAVEN_ROOT_POM} -B ${MAVEN_GOALS} -Dmaven.test.skip=true" + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + else + { + wrap([$class: 'AnsiColorBuildWrapper']) { + error "\u001B[41m[ERROR] ${MAVEN_ROOT_POM} file does not exist..." + } + } + } + catch (Exception excp) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to compile code using ${MAVEN_ROOT_POM}..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw excp + } + } +} +/******************************************** +** Function to get the version from POM +*********************************************/ +def getVersion() +{ + try { + def matcher = readFile("${MAVEN_ROOT_POM}") =~ '(.+)-.*' + matcher ? matcher[0][1] : null + } + catch (Exception error) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to get version from ${MAVEN_ROOT_POM}..." + throw error + } + } +} + +/************************************* +** Function to unit testing the code. +**************************************/ +def unitTest() +{ + try { + if ( "${MAVEN_ROOT_POM}" == "null" ) { + MAVEN_ROOT_POM = "pom.xml" + } + if (fileExists("${MAVEN_ROOT_POM}")) + { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] testing code from pom ${MAVEN_ROOT_POM}, please wait..." + println "\u001B[32mPOM VERSION => " + getVersion() + + sh "mvn -f ${MAVEN_ROOT_POM} -B test" + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + else + { + wrap([$class: 'AnsiColorBuildWrapper']) { + error "\u001B[41m[ERROR] ${MAVEN_ROOT_POM} file does not exist..." + } + } + } + catch (Exception excp) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to compile code using ${MAVEN_ROOT_POM}..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw excp + } + } +} + +/*************************************** +***** Function to upload artifacts +****************************************/ +def uploadArtifacts() +{ + try + { + if ( "${MAVEN_ROOT_POM}" == "null" ) { + MAVEN_ROOT_POM = "pom.xml" + } + + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] uploading artifact to artifact management tool, please wait..." + sh "mvn -f ${MAVEN_ROOT_POM} -e -B clean deploy" + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + catch (error) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw error + } + } +} + diff --git a/src/com/devopsnext/devops/maven/publish.groovy b/src/com/devopsnext/devops/maven/publish.groovy deleted file mode 100644 index 91e475d..0000000 --- a/src/com/devopsnext/devops/maven/publish.groovy +++ /dev/null @@ -1,40 +0,0 @@ -#!groovy -package com.devopsnext.devops.maven - -String MAVEN_ROOT_POM - -/***************************************** -***** Function to set the variables -******************************************/ -void setValue(String root_pom) -{ - this.MAVEN_ROOT_POM = root_pom -} - -/*************************************** -***** Function to upload artifacts -****************************************/ -def uploadArtifacts() -{ - try - { - if ( "${MAVEN_ROOT_POM}" == "null" ) { - MAVEN_ROOT_POM = "pom.xml" - } - - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] uploading artifact to artifact management tool, please wait..." - sh "mvn -f ${MAVEN_ROOT_POM} -e -B clean deploy" - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - catch (error) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw error - } - } -} diff --git a/src/com/devopsnext/devops/maven/test.groovy b/src/com/devopsnext/devops/maven/test.groovy deleted file mode 100644 index 55203cc..0000000 --- a/src/com/devopsnext/devops/maven/test.groovy +++ /dev/null @@ -1,65 +0,0 @@ -#!groovy -package com.devopsnext.devops.maven - -String MAVEN_ROOT_POM - -/************************************* -** Function to set the variables. -**************************************/ -void setValue(String root_pom) -{ - this.MAVEN_ROOT_POM = root_pom -} - -/************************************* -** Function to unit testing the code. -**************************************/ -def unitTest() -{ - try { - if ( "${MAVEN_ROOT_POM}" == "null" ) { - MAVEN_ROOT_POM = "pom.xml" - } - if (fileExists("${MAVEN_ROOT_POM}")) - { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] testing code from pom ${MAVEN_ROOT_POM}, please wait..." - println "\u001B[32mPOM VERSION => " + getVersion() - - sh "mvn -f ${MAVEN_ROOT_POM} -B test" - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - else - { - wrap([$class: 'AnsiColorBuildWrapper']) { - error "\u001B[41m[ERROR] ${MAVEN_ROOT_POM} file does not exist..." - } - } - } - catch (Exception excp) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to compile code using ${MAVEN_ROOT_POM}..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw excp - } - } -} -/******************************************** -** Function to get the version from POM -*********************************************/ -def getVersion() -{ - try { - def matcher = readFile("${MAVEN_ROOT_POM}") =~ '(.+)-.*' - matcher ? matcher[0][1] : null - } - catch (Exception error) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to get version from ${MAVEN_ROOT_POM}..." - throw error - } - } -} \ No newline at end of file diff --git a/src/com/devopsnext/devops/npm/build.groovy b/src/com/devopsnext/devops/npm/build.groovy deleted file mode 100644 index e9a9cb6..0000000 --- a/src/com/devopsnext/devops/npm/build.groovy +++ /dev/null @@ -1,41 +0,0 @@ -#!groovy -package com.devopsnext.devops.npm - -String NPM_RUN - -/************************************* -** Function to set the variables. -**************************************/ -void setValue(String npm_run) -{ - this.NPM_RUN = npm_run -} - -/******************************************** -** Function to Build npm modules -*********************************************/ -def npmBuild() -{ - try { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] Building NPM modules, please wait..." - if ( "${NPM_RUN}" == "null" ) { - sh "npm install" - sh "npm run build" - } - else { - sh """${NPM_RUN}""" - } - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - catch (Exception error) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to install NPM modules..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw error - } - } -} diff --git a/src/com/devopsnext/devops/npm/npmOperations.groovy b/src/com/devopsnext/devops/npm/npmOperations.groovy new file mode 100644 index 0000000..36cd521 --- /dev/null +++ b/src/com/devopsnext/devops/npm/npmOperations.groovy @@ -0,0 +1,135 @@ +#!groovy +package com.devopsnext.devops.npm + +String NPM_RUN + +/************************************* +** Function to set the variables. +**************************************/ +void setValue(String npm_run) +{ + this.NPM_RUN = npm_run +} + +/***************************************** +***** Function to set the variables +******************************************/ +void setValues(String npm_publish, String npm_repo) +{ + this.NPM_PUBLISH = npm_publish + this.NPM_REPO = npm_repo +} + +/******************************************** +** Function to Build npm modules +*********************************************/ +def npmBuild() +{ + try { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] Building NPM modules, please wait..." + if ( "${NPM_RUN}" == "null" ) { + sh "npm install" + sh "npm run build" + } + else { + sh """${NPM_RUN}""" + } + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + catch (Exception error) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to install NPM modules..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw error + } + } +} + +/******************************************** +** Function to test npm modules +*********************************************/ +def npmTest() +{ + try { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] Testing NPM modules, please wait..." + if ( "${NPM_RUN}" == "null" ) { + sh "export DISPLAY=:99; npm test" + } + else { + sh """${NPM_RUN}""" + } + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + catch (Exception error) { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to install NPM modules..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw error + } + } +} + +/*************************************** +***** Function to publish artifacts +****************************************/ +def publishModule() +{ + try + { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[32m[INFO] uploading modules to artifact management tool, please wait..." + sh """${NPM_PUBLISH}""" + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + catch (error) + { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw error + } + } +} +/******************************************** +***** Function to publish globally artifacts +*********************************************/ +def uploadModule() +{ + def NPM_RELEASE = "" + + try + { + wrap([$class: 'AnsiColorBuildWrapper']) + { + if ( "${env.GIT_BRANCH}" == "master" || "${env.GIT_BRANCH}" == "development" ) { + println "\u001B[32m[INFO] uploading modules to artifact management tool ${NPM_RELEASE}, please wait..." + sh "npm publish --registry ${NPM_RELEASE}" + } + else { + println "\u001B[32m[INFO] upload modules will only be allowed from master/development branch..." + } + currentBuild.result = 'SUCCESS' + step([$class: 'StashNotifier']) + } + } + catch (error) + { + wrap([$class: 'AnsiColorBuildWrapper']) { + println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." + currentBuild.result = 'FAILED' + step([$class: 'StashNotifier']) + throw error + } + } +} diff --git a/src/com/devopsnext/devops/npm/publish.groovy b/src/com/devopsnext/devops/npm/publish.groovy deleted file mode 100644 index c659992..0000000 --- a/src/com/devopsnext/devops/npm/publish.groovy +++ /dev/null @@ -1,70 +0,0 @@ -#!groovy -package com.devopsnext.devops.npm - -String NPM_PUBLISH, NPM_REPO, NPM_RELEASE - -/***************************************** -***** Function to set the variables -******************************************/ -void setValue(String npm_publish, String npm_repo) -{ - this.NPM_PUBLISH = npm_publish - this.NPM_REPO = npm_repo -} - -/*************************************** -***** Function to upload artifacts -****************************************/ -def publishModule() -{ - try - { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] uploading modules to artifact management tool, please wait..." - sh """${NPM_PUBLISH}""" - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - catch (error) - { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw error - } - } -} -/*************************************** -***** Function to upload artifacts -****************************************/ -def uploadModule() -{ - def NPM_RELEASE = "" - - try - { - wrap([$class: 'AnsiColorBuildWrapper']) - { - if ( "${env.GIT_BRANCH}" == "master" || "${env.GIT_BRANCH}" == "development" ) { - println "\u001B[32m[INFO] uploading modules to artifact management tool ${NPM_RELEASE}, please wait..." - sh "npm publish --registry ${NPM_RELEASE}" - } - else { - println "\u001B[32m[INFO] upload modules will only be allowed from master/development branch..." - } - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - catch (error) - { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to upload artifact on artifact management tool, please check logs..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw error - } - } -} \ No newline at end of file diff --git a/src/com/devopsnext/devops/npm/test.groovy b/src/com/devopsnext/devops/npm/test.groovy deleted file mode 100644 index 50fff5e..0000000 --- a/src/com/devopsnext/devops/npm/test.groovy +++ /dev/null @@ -1,40 +0,0 @@ -#!groovy -package com.devopsnext.devops.npm - -String NPM_RUN - -/************************************* -** Function to set the variables. -**************************************/ -void setValue(String npm_run) -{ - this.NPM_RUN = npm_run -} - -/******************************************** -** Function to Build npm modules -*********************************************/ -def npmTest() -{ - try { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[32m[INFO] Testing NPM modules, please wait..." - if ( "${NPM_RUN}" == "null" ) { - sh "export DISPLAY=:99; npm test" - } - else { - sh """${NPM_RUN}""" - } - currentBuild.result = 'SUCCESS' - step([$class: 'StashNotifier']) - } - } - catch (Exception error) { - wrap([$class: 'AnsiColorBuildWrapper']) { - println "\u001B[41m[ERROR] failed to install NPM modules..." - currentBuild.result = 'FAILED' - step([$class: 'StashNotifier']) - throw error - } - } -} \ No newline at end of file diff --git a/src/com/devopsnext/devops/sonar/maven/analysis.groovy b/src/com/devopsnext/devops/sonar/maven/mvnSonarOp.groovy similarity index 96% rename from src/com/devopsnext/devops/sonar/maven/analysis.groovy rename to src/com/devopsnext/devops/sonar/maven/mvnSonarOp.groovy index 20c431b..6a3bfea 100644 --- a/src/com/devopsnext/devops/sonar/maven/analysis.groovy +++ b/src/com/devopsnext/devops/sonar/maven/mvnSonarOp.groovy @@ -34,7 +34,7 @@ def sonar() { BRANCH = "${env.GIT_BRANCH}" } - if ( "$BRANCH" == "null" ) + else { error "\u001B[31m[ERROR] failed to proceed with Sonar analysis, unable to get Git branch..." } @@ -70,6 +70,10 @@ def sonar() } } } + +/******************************************** +***** Function to run the sonar preview +*********************************************/ def sonarPreview() { try { @@ -85,7 +89,7 @@ def sonarPreview() { BRANCH = "${env.GIT_BRANCH}" } - if ( "$BRANCH" == "null" ) + else { error "\u001B[31m[ERROR] failed to proceed with Sonar analysis, unable to get Git branch..." } diff --git a/src/com/devopsnext/devops/sonar/npm/analysis.groovy b/src/com/devopsnext/devops/sonar/npm/npmSonarOp.groovy similarity index 95% rename from src/com/devopsnext/devops/sonar/npm/analysis.groovy rename to src/com/devopsnext/devops/sonar/npm/npmSonarOp.groovy index 78b8e52..3d9bbc9 100644 --- a/src/com/devopsnext/devops/sonar/npm/analysis.groovy +++ b/src/com/devopsnext/devops/sonar/npm/npmSonarOp.groovy @@ -51,6 +51,9 @@ def sonar() } } +/******************************************** +***** Function to run the sonar preview +*********************************************/ def sonarPreview() { env.SONAR_RUNNER_HOME = tool name: 'sonar-scanner-2.8', type: 'hudson.plugins.sonar.SonarRunnerInstallation' diff --git a/vars/Git.groovy b/vars/Git.groovy index 0be7815..90e1241 100644 --- a/vars/Git.groovy +++ b/vars/Git.groovy @@ -1,6 +1,6 @@ #!groovy import com.devopsnext.devops.scm.git -import com.devopsnext.devops.email.gitEmail +import com.devopsnext.devops.email.gitNotification def call(body) { @@ -31,8 +31,8 @@ def call(body) Regards, AAA""" - def gitMail = new gitEmail() - gitMail.gitSendmail("$TO","$FROM","$SUBJECT","$BODY") + def gitMail = new gitNotification() + gitMail.gitSendEmail("$TO","$FROM","$SUBJECT","$BODY") } } diff --git a/vars/maven_Build.groovy b/vars/maven_Build.groovy index dfe49cc..f8d4947 100644 --- a/vars/maven_Build.groovy +++ b/vars/maven_Build.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.maven.build +import com.devopsnext.devops.maven.mavenOperations def call(body) { def config = [:] @@ -8,8 +8,8 @@ def call(body) { body() try { - def mvnBuild = new build() - mvnBuild.setValue("${config.MAVEN_GOALS}", "${config.MAVEN_ROOT_POM}") + def mvnBuild = new mavenOperations() + mvnBuild.setValues("${config.MAVEN_GOALS}", "${config.MAVEN_ROOT_POM}") mvnBuild.compile() } catch (Exception error) diff --git a/vars/maven_Publish.groovy b/vars/maven_Publish.groovy index 3b5881c..fb72188 100644 --- a/vars/maven_Publish.groovy +++ b/vars/maven_Publish.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.maven.publish +import com.devopsnext.devops.maven.mavenOperations def call(body) { def config = [:] @@ -9,7 +9,7 @@ def call(body) { try { if ( "${env.GIT_BRANCH}" == "development" || "${env.GIT_BRANCH}" == "master" ) { - def mvnPublish = new publish() + def mvnPublish = new mavenOperations() mvnPublish.setValue("${config.MAVEN_ROOT_POM}") mvnPublish.uploadArtifacts() } diff --git a/vars/maven_SonarAnalysis.groovy b/vars/maven_SonarAnalysis.groovy index d384f3b..452e718 100644 --- a/vars/maven_SonarAnalysis.groovy +++ b/vars/maven_SonarAnalysis.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.sonar.maven.analysis +import com.devopsnext.devops.sonar.maven.mvnSonarOp import com.devopsnext.devops.sonar.QualityGates def call(body) { @@ -10,7 +10,7 @@ def call(body) { try { if ( "${env.GIT_BRANCH}" == "development" || "${env.GIT_BRANCH}" == "master" ) { - def mvn_sonar = new analysis() + def mvn_sonar = new mvnSonarOp() mvn_sonar.setValue("${config.MAVEN_ROOT_POM}", "${config.SONAR_TOKEN}") mvn_sonar.sonar() @@ -20,7 +20,7 @@ def call(body) { qGates.checkQualityGates() } else { - def mvn_sonarPreview = new analysis() + def mvn_sonarPreview = new mvnSonarOp() mvn_sonarPreview.setValue("${config.MAVEN_ROOT_POM}", "${config.SONAR_TOKEN}") mvn_sonarPreview.sonarPreview() diff --git a/vars/maven_Test.groovy b/vars/maven_Test.groovy index f2ed883..335d460 100644 --- a/vars/maven_Test.groovy +++ b/vars/maven_Test.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.maven.test +import com.devopsnext.devops.maven.mavenOperations def call(body) { def config = [:] @@ -8,7 +8,7 @@ def call(body) { body() try { - def mvnTest = new test() + def mvnTest = new mavenOperations() mvnTest.setValue("${config.MAVEN_ROOT_POM}") mvnTest.unitTest() } diff --git a/vars/notify.groovy b/vars/notify.groovy index 1d30cae..f0927d7 100644 --- a/vars/notify.groovy +++ b/vars/notify.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.email.sendmail +import com.devopsnext.devops.email.jobStatusNotification def call(body) { @@ -9,8 +9,8 @@ def call(body) body() try { - def email = new sendmail() - email.sendmail("${config.TO}") + def email = new jobStatusNotification() + email.sendEmail("${config.TO}") } catch (Exception error) { diff --git a/vars/npm_Build.groovy b/vars/npm_Build.groovy index c17c8e9..79cdd9c 100644 --- a/vars/npm_Build.groovy +++ b/vars/npm_Build.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.npm.build +import com.devopsnext.devops.npm.npmOperations def call(body) { def config = [:] @@ -8,9 +8,9 @@ def call(body) { body() try { - def n = new build() - n.setValue("${config.NPM_RUN}") - n.npmBuild() + def npm_build = new npmOperations() + npm_build.setValue("${config.NPM_RUN}") + npm_build.npmBuild() } catch (Exception error) { diff --git a/vars/npm_Publish.groovy b/vars/npm_Publish.groovy index 0c4c002..6da575e 100644 --- a/vars/npm_Publish.groovy +++ b/vars/npm_Publish.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.npm.publish +import com.devopsnext.devops.npm.npmOperations def call(body) { def config = [:] @@ -8,8 +8,8 @@ def call(body) { body() try { - def npm_publish = new publish() - npm_publish.setValue("${config.NPM_PUBLISH}","${config.NPM_REPO}") + def npm_publish = new npmOperations() + npm_publish.setValues("${config.NPM_PUBLISH}","${config.NPM_REPO}") if ( "${config.NPM_PUBLISH}" != "null" ) { npm_publish.publishModule() diff --git a/vars/npm_SonarAnalysis.groovy b/vars/npm_SonarAnalysis.groovy index e9d2499..7e95034 100644 --- a/vars/npm_SonarAnalysis.groovy +++ b/vars/npm_SonarAnalysis.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.sonar.npm.analysis +import com.devopsnext.devops.sonar.npm.npmSonarOp import com.devopsnext.devops.sonar.QualityGates def call(body) { @@ -10,9 +10,9 @@ def call(body) { try { if ( "${env.GIT_BRANCH}" == "development" || "${env.GIT_BRANCH}" == "master" ) { - def s = new analysis() - s.setValue("${config.SONAR_PROPERTY}") - s.sonar() + def npm_sonar = new npmSonarOp() + npm_sonar.setValue("${config.SONAR_PROPERTY}") + npm_sonar.sonar() println "\u001B[32m[INFO] Checking for the Sonar qualityGates status..." @@ -20,11 +20,11 @@ def call(body) { qGates.checkQualityGates() } else { - def npm_sonarPreview = new analysis() + def npm_sonarPreview = new npmSonarOp() npm_sonarPreview.setValue("${config.SONAR_PROPERTY}") npm_sonarPreview.sonarPreview() - println "\u001B[32m[INFO] ssonar analysis will only be published to DOJO-SONAR from master/development branch..." + println "\u001B[32m[INFO] sonar analysis will only be published to DOJO-SONAR from master/development branch..." } } catch (Exception error) diff --git a/vars/npm_Test.groovy b/vars/npm_Test.groovy index 8e1d27c..ca4621b 100644 --- a/vars/npm_Test.groovy +++ b/vars/npm_Test.groovy @@ -1,5 +1,5 @@ #!groovy -import com.devopsnext.devops.npm.test +import com.devopsnext.devops.npm.npmOperations def call(body) { def config = [:] @@ -8,9 +8,9 @@ def call(body) { body() try { - def npmtest = new test() - npmtest.setValue("${config.NPM_RUN}") - npmtest.npmTest() + def npm_test = new npmOperations() + npm_test.setValue("${config.NPM_RUN}") + npm_test.npmTest() } catch (Exception error) {