Skip to content

Commit

Permalink
Update downloadFromS3 lib env vars with credentials (#2278)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya authored Jun 29, 2022
1 parent f19e15f commit 4a4b81d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
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})
downloadFromS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC})
downloadFromS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure)
downloadFromS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, 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.echo(PGP Signature Signing)
Expand Down
6 changes: 4 additions & 2 deletions tests/jenkins/jobs/DownloadFromS3_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
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})
downloadFromS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC})
downloadFromS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure)
downloadFromS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
downloadFromS3.s3Download({file=/tmp/src/path, bucket=dummy_bucket, path=/download/path, force=true})
10 changes: 5 additions & 5 deletions vars/downloadFromS3.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
void call(Map args = [:]){

withAWS(role: "${ARTIFACT_DOWNLOAD_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
s3Download(file: args.destPath, bucket: args.bucket, path: args.path, force: args.force)
void call(Map args = [:]) {
withCredentials([string(credentialsId: 'jenkins-aws-account-public', variable: 'AWS_ACCOUNT_PUBLIC')]) {
withAWS(role: 'opensearch-bundle', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
s3Download(file: args.destPath, bucket: args.bucket, path: args.path, force: args.force)
}
}

}

0 comments on commit 4a4b81d

Please sign in to comment.