-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
75 lines (67 loc) · 2.19 KB
/
Jenkinsfile
File metadata and controls
75 lines (67 loc) · 2.19 KB
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
@Library('visenze-lib')_
GIT_REPO = "visenze/visearch-sdk-javascript"
def getVersion() {
def version = sh(script: "npm run get-version --silent", returnStdout: true).trim()
return version
}
def runDockerCmd(cmd, envVars = "") {
return "docker run --rm -v ${WORKSPACE}:${WORKSPACE} ${envVars} -w ${WORKSPACE} node:18-bullseye-slim ${cmd}"
}
pipeline {
agent {
label "${params.AGENT_LABEL ?: 'build-arm64'}"
}
environment {
SEARCH_PLACEMENT_ID = 2967
SEARCH_IM_URL = "https://cdn.visenze.com/images/widget-2.jpg"
REC_PLACEMENT_ID = 1823
REC_PID = "184827-09"
ENDPOINT = "https://search-dev.visenze.com"
}
tools {
nodejs('NodeJS16') // Only to get version number; no problem in using an EOL version
}
stages {
stage('Test') {
steps {
script {
sh runDockerCmd('npm ci')
sh runDockerCmd('npm run write-version')
sh runDockerCmd('npx tsc')
withCredentials([
string(credentialsId: 'search.sg.app-1823.staging', variable: 'SEARCH_APP_KEY'),
string(credentialsId: 'rec.sg.app-2967.staging', variable: 'REC_APP_KEY'),
]) {
def envVars = "-e SEARCH_PLACEMENT_ID=${SEARCH_PLACEMENT_ID} -e SEARCH_IM_URL=${SEARCH_IM_URL} \
-e REC_PLACEMENT_ID=${REC_PLACEMENT_ID} -e REC_PID=${REC_PID} \
-e SEARCH_APP_KEY=${SEARCH_APP_KEY} -e REC_APP_KEY=${REC_APP_KEY} \
-e ENDPOINT=${ENDPOINT}"
codeclimate.testWithCoverage({
sh runDockerCmd('npm run test-with-coverage', envVars)
})
}
}
}
}
stage('Tag') {
when {
branch 'production'
}
steps {
script {
def version = getVersion()
build(
job: 'devops_github_utility_create_release',
parameters: [
string(name: 'GITHUB_REPO', value: GIT_REPO),
string(name: 'TAG_NAME', value: version),
string(name: 'TARGET_COMMITISH', value: env.BRANCH_NAME),
string(name: 'NAME', value: "${version} Release"),
string(name: 'BODY', value: "Auto release by Jenkins"),
]
)
}
}
}
}
}