forked from xmtp/example-notification-server-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build
66 lines (44 loc) · 1.5 KB
/
Build
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
#!/usr/bin/env groovy
@Library('trade.hopscotch.jenkins@multibranch-multienv') _
properties([
buildDiscarder(logRotator(numToKeepStr: '5')),
disableConcurrentBuilds()
])
node('docker') {
stage('Checkout') {
checkout scm
verifyIam()
}
stage('Pre-pipeline') {
loginToECR()
def params = [:]
params.project = "xmtp-notification-server-go"
params.branchName = env.BRANCH_NAME
if (!params.branchName) {
params.branchName = "main"
}
def buildNo = getNextBuildNumber(params)
def version = "${params.branchName}.${buildNo.trim()}"
currentBuild.displayName = version
notify(message: "Building ${params.project} version ${version}: ${env.BUILD_URL}")
stage('Build') {
def dockerRepository = "${params.project}"
checkECR(dockerRepository)
withCredentials([string(credentialsId: 'hopscotch-devops-token', variable: 'token')]) {
try {
sh"""
set -xe
set -o pipefail
echo "[build] building image"
IMAGE_TAG="465209733892.dkr.ecr.eu-west-1.amazonaws.com/${dockerRepository}:${version}" XMTP_GO_CLIENT_VERSION=${version} ./dev/build-docker --push
"""
} catch (err) {
notifyError(message: "@here Failed to build image for ${params.project} version ${version}: ${env.BUILD_URL}")
throw err
}
}
commitBuild(params, buildNo)
notifySuccess(message: "@here Built ${params.project} version ${version}: ${env.BUILD_URL}")
}
}
}