-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
61 lines (53 loc) · 1.62 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def notifyBuild(String buildStatus = '') {
def color = '#FF0000'
def slackJob = "<${env.JOB_URL}|${env.JOB_NAME}> — #${env.BUILD_NUMBER}"
def slackLinks = "<${env.BUILD_URL}|build> | <${env.BUILD_URL}/changes|changes> | <${env.BUILD_URL}/console|log> | <${env.BUILD_URL}/parameters|params>"
def slackMessage = "*${slackJob}* *( ${slackLinks} )*"
if (buildStatus == 'SUCCESS') {
color = '#36a64f'
} else {
color = '#d00000'
}
slackSend (color: color, message: slackMessage)
}
node {
def buildStats = 'STARTED'
try {
stage('configure tools') {
def nodeHome = tool name: 'Node6-LTS', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
def yarnHome = tool name: 'yarn-0.18.0', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
def mvnHome = tool name: 'maven3', type: 'maven'
env.JAVA_HOME = tool name: 'jdk1.8.0_31', type: 'jdk'
env.PATH = "${mvnHome}/bin:${yarnHome}/dist/bin:${nodeHome}/bin:${env.PATH}"
}
stage('checkout sources') {
checkout scm
sh "git clean -df"
}
// Start stages. Placed here by @opuscapita/npm-scripts
stage('install dependencies (yarn)') {
sh "yarn"
}
stage('lint code') {
sh "npm run lint"
}
stage('run test') {
sh "npm run test"
}
stage('deploy') {
if(env.RELEASE == 'TRUE') {
sh "npm run publish-release"
} else {
sh "npm run publish-snapshot"
}
}
// End stages. Placed here by @opuscapita/npm-scripts
buildStatus = 'SUCCESS'
} catch (err) {
buildStatus = 'FAILURE'
throw err
} finally {
sh "echo 'CURRENT BUILD: ${currentBuild.duration}'"
notifyBuild(buildStatus)
}
}