diff --git a/tests/jenkins/jenkinsjob-regression-files/sign-standalone-artifacts/sign-standalone-artifacts.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/sign-standalone-artifacts/sign-standalone-artifacts.jenkinsfile.txt index ae2f43a007..1eec75e275 100644 --- a/tests/jenkins/jenkinsjob-regression-files/sign-standalone-artifacts/sign-standalone-artifacts.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/sign-standalone-artifacts/sign-standalone-artifacts.jenkinsfile.txt @@ -26,8 +26,10 @@ /tmp/workspace/sign.sh /tmp/workspace/artifacts --sigtype=.sig --platform=linux ) sign-standalone-artifacts.uploadToS3({sourcePath=/tmp/workspace/artifacts, bucket=dummy_bucket_name, path=sign_artifacts_job/dummy/upload/path/20/dist/signed}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=/tmp/workspace/artifacts, bucket=dummy_bucket_name, path=sign_artifacts_job/dummy/upload/path/20/dist/signed}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=/tmp/workspace/artifacts, bucket=dummy_bucket_name, path=sign_artifacts_job/dummy/upload/path/20/dist/signed}) sign-standalone-artifacts.printArtifactDownloadUrlsForStaging({artifactFileNames=[dummy_1_artifact.tar.gz, dummy_1_artifact.tar.gz.sig, dummy_2_artifact.tar.gz, dummy_2_artifact.tar.gz.sig], uploadPath=sign_artifacts_job/dummy/upload/path/20/dist/signed}) printArtifactDownloadUrlsForStaging.echo(File dummy_1_artifact.tar.gz can be accessed using the url - https://ci.opensearch.org/ci/dbc/sign_artifacts_job/dummy/upload/path/20/dist/signed/dummy_1_artifact.tar.gz) printArtifactDownloadUrlsForStaging.echo(File dummy_1_artifact.tar.gz.sig can be accessed using the url - https://ci.opensearch.org/ci/dbc/sign_artifacts_job/dummy/upload/path/20/dist/signed/dummy_1_artifact.tar.gz.sig) diff --git a/tests/jenkins/jobs/ArchiveAssembleUpload_Jenkinsfile.txt b/tests/jenkins/jobs/ArchiveAssembleUpload_Jenkinsfile.txt index f3cc1ce349..1ba78a3a03 100644 --- a/tests/jenkins/jobs/ArchiveAssembleUpload_Jenkinsfile.txt +++ b/tests/jenkins/jobs/ArchiveAssembleUpload_Jenkinsfile.txt @@ -32,11 +32,15 @@ BuildManifest.getArtifactRoot(vars-build, 33) uploadArtifacts.echo(Uploading to s3://artifact-bucket/vars-build/1.3.0/33/linux/x64/tar) uploadArtifacts.uploadToS3({sourcePath=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) uploadArtifacts.uploadToS3({sourcePath=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) uploadArtifacts.echo(Uploading to s3://bucket/vars-build/1.3.0/33/linux/x64/tar) uploadArtifacts.withAWS({role=role, roleAccount=dummy, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) uploadArtifacts.s3Upload({file=tar/builds/opensearch/dist/opensearch-min-1.3.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/core/opensearch/1.3.0/}) diff --git a/tests/jenkins/jobs/AssembleUpload_Jenkinsfile.txt b/tests/jenkins/jobs/AssembleUpload_Jenkinsfile.txt index 48348a96a0..d11db7e96a 100644 --- a/tests/jenkins/jobs/AssembleUpload_Jenkinsfile.txt +++ b/tests/jenkins/jobs/AssembleUpload_Jenkinsfile.txt @@ -22,11 +22,15 @@ BuildManifest.getArtifactRoot(vars-build, 33) uploadArtifacts.echo(Uploading to s3://artifact-bucket/vars-build/1.1.0/33/linux/x64/tar) uploadArtifacts.uploadToS3({sourcePath=tar/builds, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/builds}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/builds}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/builds}) uploadArtifacts.uploadToS3({sourcePath=tar/dist, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/dist}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/dist}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.1.0/33/linux/x64/tar/dist}) uploadArtifacts.echo(Uploading to s3://bucket/vars-build/1.1.0/33/linux/x64/tar) uploadArtifacts.withAWS({role=role, roleAccount=dummy, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) uploadArtifacts.s3Upload({file=tar/builds/opensearch/dist/opensearch-min-1.1.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/core/opensearch/1.1.0/}) diff --git a/tests/jenkins/jobs/BuildAssembleUpload_Jenkinsfile.txt b/tests/jenkins/jobs/BuildAssembleUpload_Jenkinsfile.txt index 77872c5eec..12f6f78cdc 100644 --- a/tests/jenkins/jobs/BuildAssembleUpload_Jenkinsfile.txt +++ b/tests/jenkins/jobs/BuildAssembleUpload_Jenkinsfile.txt @@ -31,11 +31,15 @@ BuildManifest.getArtifactRoot(vars-build, 33) uploadArtifacts.echo(Uploading to s3://artifact-bucket/vars-build/1.3.0/33/linux/x64/tar) uploadArtifacts.uploadToS3({sourcePath=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/builds, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/builds}) uploadArtifacts.uploadToS3({sourcePath=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=tar/dist, bucket=artifact-bucket, path=vars-build/1.3.0/33/linux/x64/tar/dist}) uploadArtifacts.echo(Uploading to s3://bucket/vars-build/1.3.0/33/linux/x64/tar) uploadArtifacts.withAWS({role=role, roleAccount=dummy, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) uploadArtifacts.s3Upload({file=tar/builds/opensearch/dist/opensearch-min-1.3.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/core/opensearch/1.3.0/}) diff --git a/tests/jenkins/jobs/UploadIndexFile_Jenkinsfile.txt b/tests/jenkins/jobs/UploadIndexFile_Jenkinsfile.txt index c5c58c695d..8d1fff03d3 100644 --- a/tests/jenkins/jobs/UploadIndexFile_Jenkinsfile.txt +++ b/tests/jenkins/jobs/UploadIndexFile_Jenkinsfile.txt @@ -9,5 +9,7 @@ uploadIndexFile.writeJSON({file=index.json, json={latest=123}}) uploadIndexFile.echo(Uploading index.json to s3://dummy_bucket_name/test) uploadIndexFile.uploadToS3({sourcePath=index.json, bucket=dummy_bucket_name, path=test/index.json}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=index.json, bucket=dummy_bucket_name, path=test/index.json}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=index.json, bucket=dummy_bucket_name, path=test/index.json}) diff --git a/tests/jenkins/jobs/UploadToS3_Jenkinsfile.txt b/tests/jenkins/jobs/UploadToS3_Jenkinsfile.txt index 0c20963556..4228c3ae04 100644 --- a/tests/jenkins/jobs/UploadToS3_Jenkinsfile.txt +++ b/tests/jenkins/jobs/UploadToS3_Jenkinsfile.txt @@ -4,5 +4,7 @@ UploadToS3_Jenkinsfile.stage(sign, groovy.lang.Closure) UploadToS3_Jenkinsfile.script(groovy.lang.Closure) UploadToS3_Jenkinsfile.uploadToS3({sourcePath=/tmp/src/path, bucket=dummy_bucket, path=/upload/path}) - uploadToS3.withAWS({role=opensearch-bundle, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) - uploadToS3.s3Upload({file=/tmp/src/path, bucket=dummy_bucket, path=/upload/path}) + uploadToS3.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC}) + uploadToS3.withCredentials([AWS_ACCOUNT_PUBLIC], groovy.lang.Closure) + uploadToS3.withAWS({role=opensearch-bundle, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + uploadToS3.s3Upload({file=/tmp/src/path, bucket=dummy_bucket, path=/upload/path}) diff --git a/tests/jenkins/lib-testers/UploadToS3LibTester.groovy b/tests/jenkins/lib-testers/UploadToS3LibTester.groovy index 5249dad4f7..9c3cf46767 100644 --- a/tests/jenkins/lib-testers/UploadToS3LibTester.groovy +++ b/tests/jenkins/lib-testers/UploadToS3LibTester.groovy @@ -33,6 +33,10 @@ class UploadToS3LibTester extends LibFunctionTester { binding.setVariable('AWS_ACCOUNT_PUBLIC', 'dummy_account') binding.setVariable('ARTIFACT_BUCKET_NAME', 'dummy_bucket_name') helper.registerAllowedMethod("s3Upload", [Map]) + helper.registerAllowedMethod("withCredentials", [Map, Closure], { args, closure -> + closure.delegate = delegate + return helper.callClosure(closure) + }) helper.registerAllowedMethod("withAWS", [Map, Closure], { args, closure -> closure.delegate = delegate return helper.callClosure(closure) diff --git a/vars/uploadToS3.groovy b/vars/uploadToS3.groovy index 7b8c5aa02f..5302a1df08 100644 --- a/vars/uploadToS3.groovy +++ b/vars/uploadToS3.groovy @@ -1,7 +1,7 @@ -void call(Map args = [:]){ - - withAWS(role: 'opensearch-bundle', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') { - s3Upload(file: args.sourcePath, bucket: args.bucket, path: args.path) +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') { + s3Upload(file: args.sourcePath, bucket: args.bucket, path: args.path) + } } - }