From 00ddbb72c78f2e48d665f583a52cace6804712d5 Mon Sep 17 00:00:00 2001 From: Martin Reinhardt Date: Mon, 9 Sep 2019 09:03:15 +0200 Subject: [PATCH] chore(Build): Improve Jenkins build --- Jenkinsfile | 81 ++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85348ad4..c0cc5d1a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,52 +1,57 @@ -properties properties: [ - [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '10']], +#!/groovy +properties: [ + [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '0', numToKeepStr: '0']], + disableConcurrentBuilds() ] @Library('mare-build-library') def nodeJS = new de.mare.ci.jenkins.NodeJS() def git = new de.mare.ci.jenkins.Git() -node('nodejs') { - def buildNumber = env.BUILD_NUMBER - def branchName = env.BRANCH_NAME - def workspace = env.WORKSPACE - def buildUrl = env.BUILD_URL - - // PRINT ENVIRONMENT TO JOB - echo "workspace directory is $workspace" - echo "build URL is $buildUrl" - echo "build Number is $buildNumber" - echo "branch name is $branchName" - echo "PATH is $env.PATH" - - try { - stage('Checkout') { - cleanWs() - checkout scm - } +timeout(30) { + node('nodejs') { + def buildNumber = env.BUILD_NUMBER + def branchName = env.BRANCH_NAME + def workspace = env.WORKSPACE + def buildUrl = env.BUILD_URL + + // PRINT ENVIRONMENT TO JOB + echo "workspace directory is $workspace" + echo "build URL is $buildUrl" + echo "build Number is $buildNumber" + echo "branch name is $branchName" + echo "PATH is $env.PATH" + + try { + stage('Checkout') { + cleanWs() + checkout scm + } - stage('Build') { - nodeJS.nvm('install') - nodeJS.nvmRun('build') - } + stage('Build') { + nodeJS.nvm('install') + nodeJS.nvmRun('build') + } - stage('Security Checks') { - nodeJS.nvmRun('check') - } + stage('Security Checks') { + nodeJS.nvmRun('check') + } - stage('Test') { - nodeJS.nvmRun('test') - // junit '*/target/tests.js.xml' - } + stage('Test') { + nodeJS.nvmRun('test') + // junit '*/target/tests.js.xml' + } - if(git.isDevelopBranch() || git.isFeatureBranch()){ - stage('Publish NPM snapshot') { - nodeJS.publishSnapshot('.', buildNumber, branchName) + if(git.isDevelopBranch() || git.isFeatureBranch()){ + stage('Publish NPM snapshot') { + nodeJS.publishSnapshot('.', buildNumber, branchName) + } } - } - } catch (e) { - mail subject: "${env.JOB_NAME} (${buildNumber}): Error on build", to: 'github@martinreinhardt-online.de', body: "Please go to ${buildUrl}." - throw e + } catch (e) { + mail subject: "${env.JOB_NAME} (${buildNumber}): Error on build", to: 'github@martinreinhardt-online.de', body: "Please go to ${buildUrl}." + throw e + } } } +