Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions vars/uploadArtifactToS3.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/groovy

/**
* Upload jar-artifact to S3 to the given
* bucket name using the given IAM role.
*/
def call(Map config) {
def artifactFileName = require(config, "artifactFileName")
def artifactDir = require(config, "artifactDir")

def bucketName = require(config, "artifactsBucketName")
def bucketDir = require(config, "artifactsBucketDir")
def roleArn = require(config, "artifactsRoleArn")

dir(artifactDir) {
def s3Key = "$bucketDir/$artifactFileName"
def s3Url = "s3://$bucketName/$s3Key"

withAwsRole(roleArn) {
sh "aws s3 cp /$artifactDir/$artifactFileName $s3Url"
}

s3Key
}
}

private def require(Map config, String name) {
if (!config.containsKey(name)) {
throw new Exception("Missing $name")
}
return config[name]
}