forked from opensearch-project/maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps-server-release.jenkinsfile
118 lines (113 loc) · 5 KB
/
maps-server-release.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
lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
pipeline {
options {
timeout(time: 30, unit: 'MINUTES')
throttleJobProperty(
categories: [],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 0,
maxConcurrentTotal: 1,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'project',
)
}
agent {
docker {
label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v2'
args '-e JAVA_HOME=/opt/java/openjdk-11'
alwaysPull true
}
}
parameters {
string(
name: 'GIT_REFERENCE',
description: 'Git branch, tag, commitid for reference to checkout commit of OpenSearch core before running the gradle check.',
defaultValue: 'main',
trim: true
)
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.ref'],
],
tokenCredentialId: 'jenkins-opensearch-maps-server-generic-webhook-token',
causeString: 'A commit was pushed on opensearch-project/maps repository main branch causing this workflow to run',
printContributedVariables: false,
printPostContent: false,
regexpFilterText: '$ref',
regexpFilterExpression: '^(maps-server-release)-[0-9]+$'
)
}
environment {
REPO_URL="https://github.com/opensearch-project/maps"
USER_BUILD_CAUSE = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
TIMER_BUILD_CAUSE = currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause')
}
stages {
stage('Verifications and Descriptions') {
steps {
script {
def ref_final = "${GIT_REFERENCE}"
def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}"
if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) {
ref_final = ${ref}
ref_url = "${REPO_URL}/releases/tag/${ref}"
println("Triggered by GitHub: ${ref_url}")
currentBuild.description = """GitHub: <a href="${ref_url}">${ref_url}</a>"""
}
else {
println("Triggered by User/Timer: ${ref_url}")
currentBuild.description = """User/Timer: <a href="${ref_url}">${ref_url}</a>"""
}
def MAPS_PRODUCT = "opensearch-maps-server"
def MAPS_VERSION = sh (
script: "cat ${MAPS_PRODUCT}/package.json | grep version | cut -d: -f2 | grep -Eo '[0-9.]+'",
returnStdout: true
).trim()
echo("${MAPS_PRODUCT}: ${MAPS_VERSION}")
dockerBuild: {
build job: 'docker-build',
parameters: [
string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"),
string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"),
string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [
'id',
'pwd',
"cd ${MAPS_PRODUCT}/",
'ls -l',
[
'bash',
'build-image-single-arch.sh',
"-v ${MAPS_VERSION}",
"-a x64",
"-f ./Dockerfile",
"-p ${MAPS_PRODUCT}"
].join(' ')
].join(' && ')),
]
}
dockerCopy: {
build job: 'docker-copy',
parameters: [
string(name: 'SOURCE_IMAGE_REGISTRY', value: 'opensearchstaging'),
string(name: 'SOURCE_IMAGE', value: "${MAPS_PRODUCT}:${MAPS_VERSION}"),
string(name: 'DESTINATION_IMAGE_REGISTRY', value: 'opensearchproject'),
string(name: 'DESTINATION_IMAGE', value: "${MAPS_PRODUCT}:${MAPS_VERSION}")
]
}
}
}
post {
always {
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}
}