forked from eclipse-zenoh/zenoh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
159 lines (153 loc) · 4.78 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
pipeline {
agent { label 'UbuntuVM' }
parameters {
gitParameter(name: 'GIT_TAG',
type: 'PT_TAG',
description: 'The Git tag to checkout. If not specified "master" will be checkout.',
defaultValue: 'master')
string(name: 'DOCKER_TAG',
description: 'An extra Docker tag (e.g. "latest"). By default GIT_TAG will also be used as Docker tag')
}
stages {
// Same build (without Docker) on MacMini
stage('[MacMini] Checkout Git TAG') {
agent { label 'MacMini' }
steps {
cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: "${params.GIT_TAG}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/eclipse-zenoh/zenoh.git']]
])
}
}
stage('[MacMini] Setup opam dependencies') {
agent { label 'MacMini' }
steps {
sh '''
git log --graph --date=short --pretty=tformat:'%ad - %h - %cn -%d %s' -n 20 || true
OPAMJOBS=1 opam config report
OPAMJOBS=1 opam install depext conf-libev
OPAMJOBS=1 opam depext -yt
OPAMJOBS=1 opam install -t . --deps-only
'''
}
}
stage('[MacMini] Build') {
agent { label 'MacMini' }
steps {
sh '''
opam exec -- dune build @all
'''
}
}
stage('[MacMini] Tests') {
agent { label 'MacMini' }
steps {
sh '''
opam exec -- dune runtest
'''
}
}
stage('[MacMini] Package') {
agent { label 'MacMini' }
steps {
sh '''
cp -r _build/default/install eclipse-zenoh
tar czvf eclipse-zenoh-${GIT_TAG}-macosx-x86-64.tgz eclipse-zenoh/*/*.*
'''
stash includes: 'eclipse-zenoh-*-macosx-x86-64.tgz', name: 'zenohMacOS'
}
}
stage('[Ubuntu] Checkout Git TAG') {
steps {
cleanWs()
checkout([$class: 'GitSCM',
branches: [[name: "${params.GIT_TAG}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/eclipse-zenoh/zenoh.git']]
])
}
}
stage('[Ubuntu] Setup opam dependencies') {
steps {
sh '''
git log --graph --date=short --pretty=tformat:'%ad - %h - %cn -%d %s' -n 20 || true
OPAMJOBS=1 opam config report
OPAMJOBS=1 opam install depext conf-libev
OPAMJOBS=1 opam depext -yt
OPAMJOBS=1 opam install -t . --deps-only
'''
}
}
stage('[Ubuntu] Build') {
steps {
sh '''
opam exec -- dune build @all
'''
}
}
stage('[Ubuntu] Tests') {
steps {
sh '''
opam exec -- dune runtest
'''
}
}
stage('[Ubuntu] Package') {
steps {
sh '''
cp -r _build/default/install eclipse-zenoh
tar czvf eclipse-zenoh-${GIT_TAG}-Ubuntu-20.04-x64.tgz eclipse-zenoh/*/*.*
'''
}
}
stage('[Ubuntu] Docker build') {
steps {
sh '''
if [ -n "${DOCKER_TAG}" ]; then
export EXTRA_TAG="-t eclipse/zenoh:${DOCKER_TAG}"
fi
docker build -t eclipse/zenoh:${GIT_TAG} ${EXTRA_TAG} .
'''
}
}
stage('[Ubuntu] Docker publish') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub-bot',
passwordVariable: 'DOCKER_HUB_CREDS_PSW', usernameVariable: 'DOCKER_HUB_CREDS_USR')])
{
sh '''
docker login -u ${DOCKER_HUB_CREDS_USR} -p ${DOCKER_HUB_CREDS_PSW}
docker push eclipse/zenoh
docker logout
'''
}
}
}
stage('Deploy to to download.eclipse.org') {
steps {
// Unstash MacOS package to be deployed
unstash 'zenohMacOS'
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
sh '''
ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/zenoh/zenoh/${GIT_TAG}
ssh [email protected] ls -al /home/data/httpd/download.eclipse.org/zenoh/zenoh/${GIT_TAG}
scp eclipse-zenoh-${GIT_TAG}-macosx-x86-64.tgz eclipse-zenoh-${GIT_TAG}-Ubuntu-20.04-x64.tgz [email protected]:/home/data/httpd/download.eclipse.org/zenoh/zenoh/${GIT_TAG}/
'''
}
}
}
}
post {
success {
archiveArtifacts artifacts: 'eclipse-zenoh-${GIT_TAG}-macosx-x86-64.tgz, eclipse-zenoh-${GIT_TAG}-Ubuntu-20.04-x64.tgz', fingerprint: true
}
}
}