Skip to content

Commit

Permalink
chore(Build): Improve Jenkins build
Browse files Browse the repository at this point in the history
  • Loading branch information
hypery2k committed Sep 9, 2019
1 parent a288dc5 commit 00ddbb7
Showing 1 changed file with 43 additions and 38 deletions.
81 changes: 43 additions & 38 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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
}
}
}

0 comments on commit 00ddbb7

Please sign in to comment.