-
Notifications
You must be signed in to change notification settings - Fork 14
/
Jenkinsfile
102 lines (99 loc) · 2.92 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
#!groovy
def kubernetes_config = """
apiVersion: v1
kind: Pod
spec:
containers:
- name: node
image: node:12.10.0-alpine
tty: true
resources:
limits:
memory: "2Gi"
cpu: "1"
requests:
memory: "2Gi"
cpu: "1"
- name: jnlp
volumeMounts:
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
volumes:
- name: volume-known-hosts
configMap:
name: known-hosts
"""
def projectName = 'zos-resource-explorer'
def kubeLabel = projectName + '_pod_' + env.BUILD_NUMBER + '_' + env.BRANCH_NAME
kubeLabel = kubeLabel.replaceAll(/[^a-zA-Z0-9._-]+/,"")
pipeline {
agent {
kubernetes {
label kubeLabel
yaml kubernetes_config
}
}
options {
timestamps()
timeout(time: 3, unit: 'HOURS')
skipDefaultCheckout(false)
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '3'))
}
environment {
branchName = "$env.BRANCH_NAME"
workspace = "$env.WORKSPACE"
}
stages {
stage('Install & Test') {
environment {
npm_config_cache = "$env.WORKSPACE"
}
steps {
container('node') {
sh "npm ci"
sh "npm test"
}
}
}
stage('Package') {
environment {
npm_config_cache = "$env.WORKSPACE"
}
steps {
container('node') {
sh "npm run webpack-production"
sh "npx vsce package"
archiveArtifacts "*.vsix"
sh "mv *zosexplorer*.vsix zosexplorer_latest.vsix"
}
}
}
stage('Deploy') {
environment {
sshChe4z = "[email protected]"
project = "download.eclipse.org/che4z/snapshots/$projectName"
url = "$project/$branchName"
deployPath = "/home/data/httpd/$url"
}
steps {
script {
if (branchName == 'master' || branchName == 'development') {
container('jnlp') {
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
ssh $sshChe4z rm -rf $deployPath
ssh $sshChe4z mkdir -p $deployPath
scp -r $workspace/*.vsix $sshChe4z:$deployPath
'''
echo "Deployed to https://$url"
}
}
} else {
echo "Deployment skipped for branch: $branchName"
}
}
}
}
}
}