-
Notifications
You must be signed in to change notification settings - Fork 25
/
publishToMaven.groovy
34 lines (31 loc) · 1.62 KB
/
publishToMaven.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
/*
* 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 deploy opensearch artifacts to a sonatype staging repository.
@param Map args = [:] args A map of the following parameters
@param args.signingArtifactsPath <required> - Local Path to yml or artifact file. This could be path to Dir that contains artifacts or full path to yml file.
@param args.mavenArtifactsPath <required> - The local directory containing distribution files to upload to the repository. example: ~/.m2/repository where repository contains /org/opensearch
@param args.autoPublish <optional> - Set it to true to auto-release maven artifacts from staging repo to production. Default is false.
*/
void call(Map args = [:]) {
lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm))
loadCustomScript(scriptPath: 'publish/stage-maven-release.sh',
scriptName: 'stage-maven-release.sh')
def autoPublish = args.autoPublish ?: false
println("Signing Maven artifacts.")
signArtifacts(
artifactPath: args.signingArtifactsPath,
type: 'maven',
platform: 'linux',
sigtype: '.asc'
)
println("Stage and Release Maven artifacts.")
withCredentials([usernamePassword(credentialsId: 'jenkins-sonatype-creds', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD')]) {
sh("./stage-maven-release.sh ${args.mavenArtifactsPath} ${autoPublish}")
}
}