forked from interlay/interbtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·163 lines (146 loc) · 5.88 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
pipeline {
agent {
kubernetes {
yamlFile '.deploy/rust-builder-pod.yaml'
}
}
environment {
RUSTC_WRAPPER = '/usr/local/bin/sccache'
CI = 'true'
GITHUB_TOKEN = credentials('ns212-github-token')
DISCORD_WEBHOOK_URL = credentials('discord_webhook_url')
}
options {
timestamps()
ansiColor('xterm')
buildDiscarder(logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '5'))
}
stages {
stage('Test') {
steps {
container('rust') {
sh 'rustc --version'
sh 'SCCACHE_START_SERVER=1 SCCACHE_IDLE_TIMEOUT=0 /usr/local/bin/sccache'
sh '/usr/local/bin/sccache -s'
sh 'cargo fmt -- --check'
sh 'cargo check --workspace --release'
sh 'cargo test --workspace --release'
sh '/usr/local/bin/sccache -s'
}
}
}
stage('Build standalone') {
steps {
container('rust') {
sh 'SCCACHE_START_SERVER=1 SCCACHE_IDLE_TIMEOUT=0 /usr/local/bin/sccache'
sh '/usr/local/bin/sccache -s'
sh 'cargo build --release --bin interbtc-standalone'
sh 'cp target/release/interbtc-standalone target/release/interbtc-standalone'
archiveArtifacts 'target/release/interbtc-standalone'
stash(name: 'build-standalone', includes: 'Dockerfile_release, target/release/interbtc-standalone')
sh '/usr/local/bin/sccache -s'
}
}
}
stage('Build parachain') {
steps {
container('rust') {
sh 'SCCACHE_START_SERVER=1 SCCACHE_IDLE_TIMEOUT=0 /usr/local/bin/sccache'
sh '/usr/local/bin/sccache -s'
sh 'cargo build --release --bin interbtc-parachain'
archiveArtifacts 'target/release/interbtc-parachain'
stash(name: 'build-parachain', includes: 'Dockerfile_release, target/release/interbtc-parachain')
sh '/usr/local/bin/sccache -s'
}
}
}
stage('Make Image - standalone') {
when {
anyOf {
branch 'master'
tag '*'
}
}
environment {
PATH = "/busybox:$PATH"
REGISTRY = 'registry.gitlab.com' // Configure your own registry
REPOSITORY = 'interlay/interbtc'
IMAGE = 'standalone'
}
steps {
container(name: 'kaniko', shell: '/busybox/sh') {
dir('unstash') {
unstash('build-standalone')
runKaniko()
}
}
}
}
stage('Make Image - parachain') {
when {
anyOf {
branch 'master'
tag '*'
}
}
environment {
PATH = "/busybox:$PATH"
REGISTRY = 'registry.gitlab.com' // Configure your own registry
REPOSITORY = 'interlay/interbtc'
IMAGE = 'parachain'
}
steps {
container(name: 'kaniko', shell: '/busybox/sh') {
dir('unstash') {
unstash('build-parachain')
runKaniko()
}
}
}
}
stage('Create GitHub release') {
when {
anyOf {
tag '*'
}
}
steps {
sh '''
wget -q -O - https://github.com/git-chglog/git-chglog/releases/download/v0.10.0/git-chglog_0.10.0_linux_amd64.tar.gz | tar xzf -
#export PREV_TAG=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
#export TAG_NAME=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=0 --max-count=1`)
./git-chglog --output CHANGELOG.md $TAG_NAME
wget -q -O - https://github.com/cli/cli/releases/download/v1.6.2/gh_1.6.2_linux_amd64.tar.gz | tar xzf -
./gh_1.6.2_linux_amd64/bin/gh auth status
./gh_1.6.2_linux_amd64/bin/gh release -R $GIT_URL create $TAG_NAME --title $TAG_NAME -F CHANGELOG.md -d
'''
}
}
}
post {
always {
script {
env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim()
env.GIT_AUTHOR = sh (script: 'git log -1 --pretty=%cn ${GIT_COMMIT}', returnStdout: true).trim()
discordSend(
title: "${env.JOB_NAME} Finished ${currentBuild.currentResult}",
description: "```${env.GIT_COMMIT_MSG}```",
image: '',
link: "$env.RUN_DISPLAY_URL",
successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"),
thumbnail: 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png',
result: currentBuild.currentResult,
webhookURL: DISCORD_WEBHOOK_URL
)
}
}
}
}
def runKaniko() {
sh '''#!/busybox/sh
GIT_BRANCH_SLUG=$(echo $BRANCH_NAME | sed -e 's/\\//-/g')
/kaniko/executor -f `pwd`/Dockerfile_release -c `pwd` --build-arg BINARY=interbtc-parachain \
--destination=${REGISTRY}/${REPOSITORY}/${IMAGE}:${GIT_BRANCH_SLUG} \
--destination=${REGISTRY}/${REPOSITORY}/${IMAGE}:${GIT_BRANCH_SLUG}-${GIT_COMMIT:0:6}
'''
}