-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
75 lines (63 loc) · 3.07 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
node {
def branchName = (env.CHANGE_BRANCH == null) ? env.BRANCH_NAME : env.CHANGE_BRANCH
def gitURL = 'https://github.com/Watson-Personal-Assistant/skill-sdk-nodejs.git'
def skillBoilerPlate = 'Skill-Boilerplate'
def dependentRepositories = [
'CI-Test-Skill',
'Weather-Skill'
]
stage('Get the code') {
checkout([$class: 'GitSCM', branches: [[name: "${branchName}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '15eceab6-eceb-4b2b-b62d-6796f9b63acd', url: "${gitURL}"]]])
}
stage('install') {
sh 'npm install'
}
stage('Lint it') {
// lint here
}
stage('npm test') {
sh 'npm test'
}
stage('Boilerplate Test') {
def jobBuild
// Propagating (propagate: true) will make the step UI ugly, so there is a need to return the build instance and work with it
try {
jobBuild = build job: "${skillBoilerPlate}/${branchName}", parameters: [[$class: 'StringParameterValue', name: 'sdkBuildBranch', value: "${branchName}"]], propagate: false
} catch (Exception e) {
jobBuild = build job: "${skillBoilerPlate}/pre-release", parameters: [[$class: 'StringParameterValue', name: 'sdkBuildBranch', value: "${branchName}"]], propagate: false
}
def jobResult = jobBuild.getResult()
def stageName = jobBuild.getFullDisplayName()
// Showing the logs of the build job
echo jobBuild.rawBuild.log
if (jobResult != 'SUCCESS') {
error("${stageName} failed with result: ${jobResult}")
} else {
echo "Build of ${stageName} returned result: ${jobResult}"
}
}
def parallelStages = [failFast: false]
dependentRepositories.each {folderName ->
parallelStages["Build dependent skill - ${folderName}"] = {
stage("Build dependent skill - ${folderName}") {
def jobBuild
// Propagating (propagate: true) will make the step UI ugly, so there is a need to return the build instance and work with it
try {
jobBuild = build job: "${folderName}/${branchName}", parameters: [[$class: 'StringParameterValue', name: 'sdkBuildBranch', value: "${branchName}"]], propagate: false
} catch (Exception e) {
jobBuild = build job: "${folderName}/master", parameters: [[$class: 'StringParameterValue', name: 'sdkBuildBranch', value: "${branchName}"]], propagate: false
}
def jobResult = jobBuild.getResult()
def stageName = jobBuild.getFullDisplayName()
// Showing the logs of the build job
echo jobBuild.rawBuild.log
if (jobResult != 'SUCCESS') {
error("${stageName} failed with result: ${jobResult}")
} else {
echo "Build of ${stageName} returned result: ${jobResult}"
}
}
}
}
parallel parallelStages
}