This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
126 lines (116 loc) · 3.64 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!groovy
def slackChannel = '#als-extension-bot'
def getVersion(alsVersion) {
if(alsVersion.contains("-SNAPSHOT"))
"0.4.0-SNAPSHOT"
else "0.3.${env.BUILD_NUMBER}"
}
def getNexusFullUri(version){
if(version.contains("-SNAPSHOT"))
"https://repository-master.mulesoft.org/nexus/content/repositories/snapshots/com/mulesoft/als/alsvscode/${version}"
else
"https://repository-master.mulesoft.org/nexus/content/repositories/releases/com/mulesoft/als/alsvscode/${version}"
}
def getNexusUri(version){
if(version.contains("-SNAPSHOT"))
"https://repository-master.mulesoft.org/nexus/content/repositories/snapshots"
else
"https://repository-master.mulesoft.org/nexus/content/repositories/releases"
}
pipeline {
agent {
dockerfile true
}
parameters {
string(name: 'ALS_VERSION', defaultValue: '4.2.0-SNAPSHOT.357', description: 'ALS node client version')
}
environment {
VERSION = getVersion("$ALS_VERSION")
ALS_VERSION = "$ALS_VERSION" // Internal parameter to env variable
NEXUS = credentials('exchange-nexus')
NEXUSIQ = credentials('nexus-iq')
NEXUSURL = getNexusUri("$VERSION")
NEXUSFULLURL = getNexusFullUri("$VERSION")
NPM_TOKEN = credentials('npm-mulesoft')
NPM_CONFIG_PRODUCTION = false
NODE_MODULES_CACHE = false
NODE_OPTIONS = '--max_old_space_size=4096'
}
stages {
stage('Set versions') {
steps {
script {
sh 'bash set_versions.sh'
}
}
}
stage('Install & Compile') {
steps {
script {
def exitCode = 1
exitCode = sh script:"bash install_compile.sh", returnStatus:true
if(exitCode != 0) {
sh "echo ${exitCode}"
error("Failed Install & Compile")
}
}
}
}
stage('Test') {
steps {
script {
def exitCode = 1
exitCode = sh script:"bash test.sh", returnStatus:true
if(exitCode != 0) {
sh "echo ${exitCode}"
error("Failed tests")
}
}
}
}
stage('Package') {
when {
anyOf {
branch 'publish/*'
branch 'master'
}
}
steps {
script {
sh 'vsce package'
}
}
}
stage('Upload') {
when {
anyOf {
branch 'publish/*'
branch 'master'
}
}
steps {
script {
sh 'chmod +x gradlew'
sh "./gradlew --info --stacktrace publish"
}
}
}
stage("Report to Slack") {
when {
anyOf {
branch 'publish/*'
branch 'master'
}
}
steps {
script {
slackSend color: '#00FF00', channel: "${slackChannel}", message: ":ok_hand: VS Code extension published :ok_hand:\nversion: ${env.VERSION}\nALS version: ${ALS_VERSION}\nlink: ${NEXUSFULLURL}"
}
}
}
}
}
def runWithXvfb(String command) {
def status = sh script:"xvfb-run ${command}", returnStatus:true
return status
}