forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrating Maven sign and release jenkins jobs (opensearch-project#1520)
* Migrate the maven sign release script to build repo Signed-off-by: Zelin Hao <[email protected]>
- Loading branch information
Showing
23 changed files
with
369 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
jenkins/opensearch-maven-release/maven-sign-release.jenkinsfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
agent { | ||
docker { | ||
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host' | ||
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211130' | ||
alwaysPull true | ||
} | ||
} | ||
parameters { | ||
string( | ||
name: 'BUILD_ID', | ||
description: 'Build ID of the OpenSearch distribution artifacts to be staged.', | ||
trim: true | ||
) | ||
string( | ||
name: 'VERSION', | ||
description: 'Version of the OpenSearch distribution artifacts to be staged.', | ||
trim: true | ||
) | ||
} | ||
environment { | ||
ARTIFACT_PATH = "distribution-build-opensearch/${VERSION}/${BUILD_ID}/linux/x64/builds" | ||
} | ||
stages { | ||
stage('sign') { | ||
steps { | ||
script { | ||
echo "Downloading from S3." | ||
downloadFromS3( | ||
destPath: "$WORKSPACE/artifacts", | ||
bucket: "${ARTIFACT_BUCKET_NAME}", | ||
path: "${ARTIFACT_PATH}/", | ||
force: true | ||
) | ||
echo "Signing Maven artifacts." | ||
signArtifacts( | ||
artifactPath: "$WORKSPACE/artifacts/$ARTIFACT_PATH/opensearch/manifest.yml", | ||
type: 'maven', | ||
platform: 'linux' | ||
) | ||
} | ||
} | ||
} | ||
stage('stage maven artifacts') { | ||
tools { | ||
maven "maven-3.8.2" | ||
} | ||
environment { | ||
REPO_URL = "https://aws.oss.sonatype.org/" | ||
STAGING_PROFILE_ID = "${SONATYPE_STAGING_PROFILE_ID}" | ||
BUILD_ID = "${BUILD_ID}" | ||
} | ||
steps { | ||
script { | ||
// stage artifacts for release with Sonatype | ||
withCredentials([usernamePassword(credentialsId: 'Sonatype', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD')]) { | ||
sh('$WORKSPACE/publish/stage-maven-release.sh $WORKSPACE/artifacts/$ARTIFACT_PATH/maven-signed') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post() { | ||
always { | ||
script { | ||
postCleanup() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
|
||
class TestDownloadFromS3 extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
|
||
this.registerLibTester(new DownloadFromS3LibTester('/tmp/src/path' , 'dummy_bucket', '/download/path', true)) | ||
|
||
super.setUp() | ||
} | ||
|
||
@Test | ||
public void testDownloadFromS3() { | ||
super.testPipeline("tests/jenkins/jobs/DownloadFromS3_Jenkinsfile") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class TestMavenSignReleaseJob extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
|
||
def destPath = "${this.workspace}/artifacts" | ||
|
||
def manifestPath = "${this.workspace}/artifacts/distribution-build-opensearch/1.0.0/123/linux/x64/builds/opensearch/manifest.yml" | ||
|
||
def artifactsPath = 'distribution-build-opensearch/1.0.0/123/linux/x64/builds/' | ||
|
||
def bucketName = 'job-s3-bucket-name' | ||
|
||
this.registerLibTester(new DownloadFromS3LibTester(destPath, bucketName, artifactsPath, true)) | ||
|
||
this.registerLibTester(new SignArtifactsLibTester( '.sig', 'linux', manifestPath, 'maven', null)) | ||
|
||
super.setUp() | ||
|
||
// Variables for Maven Sign Release job | ||
binding.setVariable('VERSION', '1.0.0') | ||
binding.setVariable('BUILD_ID', '123') | ||
binding.setVariable('ARTIFACT_PATH', 'distribution-build-opensearch/1.0.0/123/linux/x64/builds') | ||
binding.setVariable('ARTIFACT_BUCKET_NAME', bucketName) | ||
binding.setVariable('SONATYPE_STAGING_PROFILE_ID', 'dummy_id') | ||
|
||
helper.registerAllowedMethod('checkout', [Map], {}) | ||
|
||
} | ||
|
||
@Test | ||
void MavenSignRelease_test() { | ||
super.testPipeline('jenkins/opensearch-maven-release/maven-sign-release.jenkinsfile', | ||
'tests/jenkins/jenkinsjob-regression-files/maven-sign-release/maven-sign-release.jenkinsfile') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...jenkins/jenkinsjob-regression-files/maven-sign-release/maven-sign-release.jenkinsfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
maven-sign-release.run() | ||
maven-sign-release.legacySCM(groovy.lang.Closure) | ||
maven-sign-release.library({identifier=jenkins@20211123, retriever=null}) | ||
maven-sign-release.pipeline(groovy.lang.Closure) | ||
maven-sign-release.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211130, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) | ||
maven-sign-release.stage(sign, groovy.lang.Closure) | ||
maven-sign-release.script(groovy.lang.Closure) | ||
maven-sign-release.echo(Downloading from S3.) | ||
maven-sign-release.downloadFromS3({destPath=/tmp/workspace/artifacts, bucket=job-s3-bucket-name, path=distribution-build-opensearch/1.0.0/123/linux/x64/builds/, force=true}) | ||
downloadFromS3.withAWS({role=Dummy_Download_Role, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) | ||
downloadFromS3.s3Download({file=/tmp/workspace/artifacts, bucket=job-s3-bucket-name, path=distribution-build-opensearch/1.0.0/123/linux/x64/builds/, force=true}) | ||
maven-sign-release.echo(Signing Maven artifacts.) | ||
maven-sign-release.signArtifacts({artifactPath=/tmp/workspace/artifacts/distribution-build-opensearch/1.0.0/123/linux/x64/builds/opensearch/manifest.yml, type=maven, platform=linux}) | ||
signArtifacts.fileExists(/tmp/workspace/sign.sh) | ||
signArtifacts.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main}) | ||
signArtifacts.sh(curl -sSL https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --import -) | ||
signArtifacts.usernamePassword({credentialsId=github_bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN}) | ||
signArtifacts.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) | ||
signArtifacts.sh( | ||
#!/bin/bash | ||
set +x | ||
export ROLE=dummy_signer_client_role | ||
export EXTERNAL_ID=signer_client_external_id | ||
export UNSIGNED_BUCKET=signer_client_unsigned_bucket | ||
export SIGNED_BUCKET=signer_client_signed_bucket | ||
|
||
/tmp/workspace/sign.sh /tmp/workspace/artifacts/distribution-build-opensearch/1.0.0/123/linux/x64/builds/opensearch/manifest.yml --type=maven --platform=linux | ||
) | ||
maven-sign-release.stage(stage maven artifacts, groovy.lang.Closure) | ||
maven-sign-release.script(groovy.lang.Closure) | ||
maven-sign-release.usernamePassword({credentialsId=Sonatype, usernameVariable=SONATYPE_USERNAME, passwordVariable=SONATYPE_PASSWORD}) | ||
maven-sign-release.withCredentials([[SONATYPE_USERNAME, SONATYPE_PASSWORD]], groovy.lang.Closure) | ||
maven-sign-release.sh($WORKSPACE/publish/stage-maven-release.sh $WORKSPACE/artifacts/$ARTIFACT_PATH/maven-signed) | ||
maven-sign-release.script(groovy.lang.Closure) | ||
maven-sign-release.postCleanup() | ||
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('download') { | ||
steps { | ||
script { | ||
downloadFromS3( | ||
destPath: '/tmp/src/path', | ||
bucket: 'dummy_bucket', | ||
path: '/download/path', | ||
force: true | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DownloadFromS3_Jenkinsfile.run() | ||
DownloadFromS3_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
DownloadFromS3_Jenkinsfile.echo(Executing on agent [label:none]) | ||
DownloadFromS3_Jenkinsfile.stage(download, groovy.lang.Closure) | ||
DownloadFromS3_Jenkinsfile.script(groovy.lang.Closure) | ||
DownloadFromS3_Jenkinsfile.downloadFromS3({destPath=/tmp/src/path, bucket=dummy_bucket, path=/download/path, force=true}) | ||
downloadFromS3.withAWS({role=Dummy_Download_Role, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) | ||
downloadFromS3.s3Download({file=/tmp/src/path, bucket=dummy_bucket, path=/download/path, force=true}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.