forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publishToArtifactsProdBucket.groovy
44 lines (43 loc) · 2.05 KB
/
publishToArtifactsProdBucket.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
39
40
41
42
43
44
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/**
* Library to sign and upload artifacts to artifacts.opensearch.org
@param Map[assumedRoleName] <required> - IAM role to be assumed for uploading artifacts
@param Map[source] <required> - Path to yml or artifact file.
@param Map[destination] <required> - Artifact type in the manifest, [type] is required for signing yml.
@param Map[signingPlatform] <optional> - The distribution platform for signing. Defaults to linux
@param Map[sigType] <optional> - signature type. Defaults to '.sig'
@param Map[sigOverwrite]<optional> - Allow output artifacts to overwrite the existing artifacts. Defaults to false
*/
void call(Map args = [:]) {
lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm))
println('Signing the artifacts')
if (args.signingPlatform == 'windows' || args.signingPlatform == 'mac' || args.signingPlatform == 'jar_signer') {
signArtifacts(
artifactPath: args.source,
platform: args.signingPlatform,
overwrite: args.sigOverwrite ?: true
)
} else {
signArtifacts(
artifactPath: args.source,
platform: args.signingPlatform ?: 'linux',
sigtype: args.sigType ?: '.sig',
overwrite: args.sigOverwrite ?: false
)
}
println('Uploading the artifacts')
withCredentials([
string(credentialsId: 'jenkins-aws-production-account', variable: 'AWS_ACCOUNT_ARTIFACT'),
string(credentialsId: 'jenkins-artifact-production-bucket-name', variable: 'ARTIFACT_PRODUCTION_BUCKET_NAME')]) {
withAWS(role: "${args.assumedRoleName}", roleAccount: "${AWS_ACCOUNT_ARTIFACT}", duration: 900, roleSessionName: 'jenkins-session') {
s3Upload(file: "${args.source}", bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "${args.destination}")
}
}
}