Skip to content

Commit

Permalink
Update uploadArtifacts lib env vars with credentials
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya committed Jun 23, 2022
1 parent 73a8084 commit d60482b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 60 deletions.
34 changes: 19 additions & 15 deletions tests/jenkins/jobs/ArchiveAssembleUpload_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@
BuildManifest.asBoolean()
BuildManifest.getMinArtifact()
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.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.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/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.3.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/bundle/opensearch/1.3.0/})
uploadArtifacts.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-artifact-production-bucket-name, variable=ARTIFACT_PRODUCTION_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-aws-production-account, variable=AWS_ACCOUNT_ARTIFACT})
uploadArtifacts.withCredentials([ARTIFACT_BUCKET_NAME, ARTIFACT_PRODUCTION_BUCKET_NAME, AWS_ACCOUNT_ARTIFACT], groovy.lang.Closure)
uploadArtifacts.echo(Uploading to s3://ARTIFACT_BUCKET_NAME/vars-build/1.3.0/33/linux/x64/tar)
uploadArtifacts.uploadToS3({sourcePath=tar/builds, bucket=ARTIFACT_BUCKET_NAME, 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_NAME, path=vars-build/1.3.0/33/linux/x64/tar/builds})
uploadArtifacts.uploadToS3({sourcePath=tar/dist, bucket=ARTIFACT_BUCKET_NAME, 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_NAME, path=vars-build/1.3.0/33/linux/x64/tar/dist})
uploadArtifacts.echo(Uploading to s3://ARTIFACT_PRODUCTION_BUCKET_NAME/vars-build/1.3.0/33/linux/x64/tar)
uploadArtifacts.withAWS({role=role, roleAccount=AWS_ACCOUNT_ARTIFACT, 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=ARTIFACT_PRODUCTION_BUCKET_NAME, path=release-candidates/core/opensearch/1.3.0/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.3.0-linux-x64.tar.gz, bucket=ARTIFACT_PRODUCTION_BUCKET_NAME, path=release-candidates/bundle/opensearch/1.3.0/})
BuildManifest.getArtifactRootUrl(https://ci.opensearch.org/dbc, vars-build, 33)
Messages.asBoolean()
Messages.add(stage, https://ci.opensearch.org/dbc/vars-build/1.3.0/33/linux/x64/tar/builds/opensearch/manifest.yml
Expand Down
34 changes: 19 additions & 15 deletions tests/jenkins/jobs/AssembleUpload_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@
BuildManifest.asBoolean()
BuildManifest.getMinArtifact()
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.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.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/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.1.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/bundle/opensearch/1.1.0/})
uploadArtifacts.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-artifact-production-bucket-name, variable=ARTIFACT_PRODUCTION_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-aws-production-account, variable=AWS_ACCOUNT_ARTIFACT})
uploadArtifacts.withCredentials([ARTIFACT_BUCKET_NAME, ARTIFACT_PRODUCTION_BUCKET_NAME, AWS_ACCOUNT_ARTIFACT], groovy.lang.Closure)
uploadArtifacts.echo(Uploading to s3://ARTIFACT_BUCKET_NAME/vars-build/1.1.0/33/linux/x64/tar)
uploadArtifacts.uploadToS3({sourcePath=tar/builds, bucket=ARTIFACT_BUCKET_NAME, 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_NAME, path=vars-build/1.1.0/33/linux/x64/tar/builds})
uploadArtifacts.uploadToS3({sourcePath=tar/dist, bucket=ARTIFACT_BUCKET_NAME, 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_NAME, path=vars-build/1.1.0/33/linux/x64/tar/dist})
uploadArtifacts.echo(Uploading to s3://ARTIFACT_PRODUCTION_BUCKET_NAME/vars-build/1.1.0/33/linux/x64/tar)
uploadArtifacts.withAWS({role=role, roleAccount=AWS_ACCOUNT_ARTIFACT, 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=ARTIFACT_PRODUCTION_BUCKET_NAME, path=release-candidates/core/opensearch/1.1.0/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.1.0-linux-x64.tar.gz, bucket=ARTIFACT_PRODUCTION_BUCKET_NAME, path=release-candidates/bundle/opensearch/1.1.0/})
BuildManifest.getArtifactRootUrl(https://ci.opensearch.org/dbc, vars-build, 33)
Messages.asBoolean()
Messages.add(stage, https://ci.opensearch.org/dbc/vars-build/1.1.0/33/linux/x64/tar/builds/opensearch/manifest.yml
Expand Down
34 changes: 19 additions & 15 deletions tests/jenkins/jobs/BuildAssembleUpload_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@
BuildManifest.asBoolean()
BuildManifest.getMinArtifact()
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.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.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/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.3.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/bundle/opensearch/1.3.0/})
uploadArtifacts.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-artifact-production-bucket-name, variable=ARTIFACT_PRODUCTION_BUCKET_NAME})
uploadArtifacts.string({credentialsId=jenkins-aws-production-account, variable=AWS_ACCOUNT_ARTIFACT})
uploadArtifacts.withCredentials([ARTIFACT_BUCKET_NAME, ARTIFACT_PRODUCTION_BUCKET_NAME, AWS_ACCOUNT_ARTIFACT], groovy.lang.Closure)
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.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.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/})
uploadArtifacts.s3Upload({file=tar/dist/opensearch/opensearch-1.3.0-linux-x64.tar.gz, bucket=bucket, path=release-candidates/bundle/opensearch/1.3.0/})
BuildManifest.getArtifactRootUrl(https://ci.opensearch.org/dbc, vars-build, 33)
Messages.asBoolean()
Messages.add(stage, https://ci.opensearch.org/dbc/vars-build/1.3.0/33/linux/x64/tar/builds/opensearch/manifest.yml
Expand Down
36 changes: 21 additions & 15 deletions vars/uploadArtifacts.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ void call(Map args = [:]) {
def distribution = buildManifest.build.distribution

def artifactPath = buildManifest.getArtifactRoot("${JOB_NAME}", "${BUILD_NUMBER}")
echo "Uploading to s3://${ARTIFACT_BUCKET_NAME}/${artifactPath}"

uploadToS3(
sourcePath: "${distribution}/builds",
bucket: "${ARTIFACT_BUCKET_NAME}",
path: "${artifactPath}/builds"
)
withCredentials([
string(credentialsId: 'jenkins-artifact-bucket-name', variable: 'ARTIFACT_BUCKET_NAME'),
string(credentialsId: 'jenkins-artifact-production-bucket-name', variable: 'ARTIFACT_PRODUCTION_BUCKET_NAME'),
string(credentialsId: 'jenkins-aws-production-account', variable: 'AWS_ACCOUNT_ARTIFACT'),]) {
echo "Uploading to s3://${ARTIFACT_BUCKET_NAME}/${artifactPath}"

uploadToS3(
sourcePath: "${distribution}/dist",
bucket: "${ARTIFACT_BUCKET_NAME}",
path: "${artifactPath}/dist"
)
uploadToS3(
sourcePath: "${distribution}/builds",
bucket: "${ARTIFACT_BUCKET_NAME}",
path: "${artifactPath}/builds"
)

uploadToS3(
sourcePath: "${distribution}/dist",
bucket: "${ARTIFACT_BUCKET_NAME}",
path: "${artifactPath}/dist"
)

echo "Uploading to s3://${ARTIFACT_PRODUCTION_BUCKET_NAME}/${artifactPath}"
echo "Uploading to s3://${ARTIFACT_PRODUCTION_BUCKET_NAME}/${artifactPath}"

withAWS(role: "${ARTIFACT_PROMOTION_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_ARTIFACT}", duration: 900, roleSessionName: 'jenkins-session') {
s3Upload(file: "${distribution}/builds/${productFilename}/${minArtifactPath}", bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "release-candidates/core/${productFilename}/${buildManifest.build.version}/")
s3Upload(file: "${distribution}/dist/${productFilename}/${packageName}", bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "release-candidates/bundle/${productFilename}/${buildManifest.build.version}/")
withAWS(role: "${ARTIFACT_PROMOTION_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_ARTIFACT}", duration: 900, roleSessionName: 'jenkins-session') {
s3Upload(file: "${distribution}/builds/${productFilename}/${minArtifactPath}", bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "release-candidates/core/${productFilename}/${buildManifest.build.version}/")
s3Upload(file: "${distribution}/dist/${productFilename}/${packageName}", bucket: "${ARTIFACT_PRODUCTION_BUCKET_NAME}", path: "release-candidates/bundle/${productFilename}/${buildManifest.build.version}/")
}
}

def baseUrl = buildManifest.getArtifactRootUrl("${PUBLIC_ARTIFACT_URL}", "${JOB_NAME}", "${BUILD_NUMBER}")
Expand Down

0 comments on commit d60482b

Please sign in to comment.