forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetManifestSHA.groovy
38 lines (32 loc) · 1.27 KB
/
getManifestSHA.groovy
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
Map call(Map args = [:]) {
String inputManifest = args.inputManifest ?: "manifests/${INPUT_MANIFEST}"
String jobName = args.jobName ?: "${JOB_NAME}"
buildManifest(
args + [
inputManifest: inputManifest,
lock: true
]
)
String manifestLock = "${inputManifest}.lock"
String manifestSHA = sha1(manifestLock)
echo "Manifest SHA: ${manifestSHA}"
def lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))
def inputManifestObj = lib.jenkins.InputManifest.new(readYaml(file: manifestLock))
String shasRoot = inputManifestObj.getSHAsRoot(jobName)
String manifestSHAPath = "${shasRoot}/${manifestSHA}.yml"
echo "Manifest lock: ${manifestLock}"
echo "Manifest SHA path: ${manifestSHAPath}"
Boolean manifestSHAExists = false
withAWS(role: 'opensearch-bundle', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
if (s3DoesObjectExist(bucket: "${ARTIFACT_BUCKET_NAME}", path: manifestSHAPath)) {
manifestSHAExists = true
}
}
echo "Manifest SHA exists: ${manifestSHAExists}"
return [
sha: manifestSHA,
lock: manifestLock,
path: manifestSHAPath,
exists: manifestSHAExists
]
}