Skip to content

Instantly share code, notes, and snippets.

@bombel2
Forked from twasink/publish_to_s3_Jenkinsfile
Created August 31, 2019 23:52
Show Gist options
  • Save bombel2/69955078b9455acefa7d61117fdb5fdd to your computer and use it in GitHub Desktop.
Save bombel2/69955078b9455acefa7d61117fdb5fdd to your computer and use it in GitHub Desktop.
#!groovy
node {
// Need to replace the '%2F' used by Jenkins to deal with / in the path (e.g. story/...)
// because tests that do getResource will escape the % again, and the test files can't be found
ws("workspace/${env.JOB_NAME}/${env.BRANCH_NAME}".replace('%2F', '_')) {
// Mark the code checkout 'stage'....
stage 'Checkout'
checkout scm
// Mark the code build 'stage'....
stage 'Build'
def mvnHome = tool 'maven-3.3.9'
sh "${mvnHome}/bin/mvn clean verify -B"
junit testResults: '**/surefire-reports/*.xml'
stage 'Publish'
step([$class: 'S3BucketPublisher',
dontWaitForConcurrentBuildCompletion: false,
entries: [[bucket: '${env.MY_S3_BUCKET}',
excludedFile: '',
flatten: false,
gzipFiles: false,
keepForever: false,
managedArtifacts: true,
noUploadOnFailure: true,
selectedRegion: 'us-east-1',
sourceFile: '**/target/*.war',
storageClass: 'STANDARD',
uploadFromSlave: true,
useServerSideEncryption: false
]],
profileName: 's3Artefacts'])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment