-
Notifications
You must be signed in to change notification settings - Fork 18
/
Jenkinsfile
206 lines (184 loc) · 8.23 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env groovy
def prepareRemoteFolders(def emptyDir, def upload_dir, def distroVersion, def packageJson) {
// Ensure proper folders are created
echo "Creating empty remote dirs for given version output"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/p2/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/p2/plugins/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/vscode-extension/'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir} <<< \$'mkdir ${UPLOAD_PATH}/${upload_dir}/rsp-server-community/vscode-extension/${packageJson.version}/'"
// Ensure proper folders are created *AND* emptied
echo "Ensuring some remote dirs are empty"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/p2/plugins/ <<< \$'rm *'"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/vscode-extension/${packageJson.version}/ <<< \$'rm *'"
}
pipeline {
agent { label 'rhel8' }
options {
timeout(time: 30, unit: 'MINUTES')
timestamps()
}
tools {
maven 'maven3-latest'
jdk 'openjdk-17'
}
stages {
stage('Checkout SCM') {
steps {
deleteDir()
git url: "https://github.com/${params.FORK}/rsp-server-community.git", branch: params.BRANCH
}
}
stage('Install requirements') {
steps {
script {
def nodeHome = tool 'nodejs-lts'
env.PATH="${env.PATH}:${nodeHome}/bin"
}
sh "npm install -g typescript || true"
sh "npm install -g vsce || true"
sh "npm install -g ovsx || true"
}
}
stage ('Build community server with Java 11 runtime') {
steps {
dir("rsp") {
sh 'mvn clean install -fae -B'
}
archiveArtifacts 'rsp/distribution/distribution*/target/org.jboss.tools.rsp.*.zip,rsp/site/target/repository/**'
}
}
stage('SonarCloud Report') {
when {
expression { params.SONAR }
}
steps {
dir( "rsp" ) {
script {
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
sh '''
set +x
mvn -B -P sonar sonar:sonar -Dsonar.login="${SONAR_TOKEN}"
'''
}
}
}
}
}
stage("Build extension") {
steps {
dir("vscode") {
sh "npm install"
sh "npm run build"
}
}
}
stage('Test extension') {
steps {
withEnv(['JUNIT_REPORT_PATH=report.xml', 'CODE_TESTS_WORKSPACE=c:/unknown']) {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
dir("vscode") {
sh "npm test --silent"
junit 'report.xml'
}
}
}
}
}
stage('Package VSCode extension') {
steps {
script {
dir("vscode") {
try {
def packageJson = readJSON file: 'package.json'
sh "vsce package -o adapters-community-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
}
finally {
archiveArtifacts artifacts: '*.vsix'
}
}
}
}
}
}
post {
success {
script {
stage('Uploading bits') {
sh "ls *"
def packageJson = readJSON file: 'vscode/package.json'
// If releasing push files into stable directory
def upload_dir = params.publishToMarketPlace ? 'stable' : 'snapshots'
sh "echo 'Pushing bits into ${upload_dir}'"
// Make an empty directory
sh "echo Creating empty directory"
def emptyDir = sh script: "mktemp -d | tr -d '\n'", returnStdout: true
sh "chmod 775 ${emptyDir}"
def distroVersion = sh script: "ls rsp/distribution/distribution.community/target/*.zip | cut --complement -f 1 -d '-' | rev | cut -c5- | rev | tr -d '\n'", returnStdout: true
sh "echo Distro version: ${distroVersion}"
// prepare remote folder structure
sh "echo Preparing remote folders"
prepareRemoteFolders(emptyDir, upload_dir, distroVersion, packageJson)
// Begin Copying Files Over and publish to marketplace
// Upload the p2 update site. This logic only works because all plugins are jars.
// If we ever have exploded bundles here, this will need to be redone
sh "echo Uploading site"
def siteRepositoryFilesToPush = findFiles(glob: 'rsp/site/target/repository/*')
for (i = 0; i < siteRepositoryFilesToPush.length; i++) {
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/p2/ <<< \$'put -p ${siteRepositoryFilesToPush[i].path}'"
}
sh "echo Uploading site/plugins"
def sitePluginFilesToPush = findFiles(glob: 'rsp/site/target/repository/plugins/*')
for (i = 0; i < sitePluginFilesToPush.length; i++) {
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/p2/plugins/ <<< \$'put -p ${sitePluginFilesToPush[i].path}'"
}
// Upload distributions / zips
sh "echo Uploading distro files"
def filesToPush = findFiles(glob: '**/*.zip')
for (i = 0; i < filesToPush.length; i++) {
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/${distroVersion}/ <<< \$'put -p ${filesToPush[i].path}'"
}
// Upload VSIX file
sh "echo Uploading vsix"
def vsixToPush = findFiles(glob: '**/*.vsix')
for (i = 0; i < vsixToPush.length; i++) {
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/vscode-extension/${packageJson.version}/ <<< \$'put -p ${vsixToPush[i].path}'"
}
sh "echo org.jboss.tools.rsp.community.distribution.latest.version=${distroVersion} > LATEST"
sh "echo org.jboss.tools.rsp.community.distribution.latest.url=https://download.jboss.org/jbosstools/adapters/${upload_dir}/rsp-server-community/distributions/${distroVersion}/org.jboss.tools.rsp.server.community.distribution-${distroVersion}.zip >> LATEST"
sh "sftp -C ${UPLOAD_USER_AT_HOST}:${UPLOAD_PATH}/${upload_dir}/rsp-server-community/distributions/ <<< \$'put -p LATEST'"
// publish to ovsx
if (params.publishToOVSX) {
stage('Publish to OVSX') {
timeout(time:5, unit:'DAYS') {
input message:'Approve publishing to OVSX?'
}
sh "echo 'Publishing to OVSX'"
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
def vsix = findFiles(glob: '**/*.vsix')
sh "echo Publishing ${vsix[0].path}"
sh 'ovsx publish -p ${OVSX_TOKEN} --packagePath' + " ${vsix[0].path}"
}
}
}
// publish to market place
if (params.publishToMarketPlace) {
stage('Publish to Marketplace') {
timeout(time:5, unit:'DAYS') {
input message:'Approve publishing to MarketPlace?'
}
sh "echo 'Publishing to marketplace'"
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
def vsix = findFiles(glob: '**/*.vsix')
sh "echo Publishing ${vsix[0].path}"
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}"
}
}
}
}
}
}
}
}