Use the built-in to add a redirect

This commit is contained in:
R. Tyler Croy 2018-01-03 19:45:02 -08:00
parent 72504eae64
commit 25724a118d
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
1 changed files with 11 additions and 1 deletions

View File

@ -8,7 +8,17 @@ def call(Map args) {
String uploadScript = libraryResource 'io/codevalet/externalartifacts/upload-file-azure.sh'
writeFile file: uploadScriptName, text: uploadScript
sh 'ls -lah'
sh "bash ${uploadScriptName} ${args.artifacts}"
String uploadedUrl = sh(script: "bash ${uploadScriptName} ${args.artifacts}",
returnStdout: true).trim()
echo uploadedUrl
if (uploadedUrl.match(/https\:\/\//)) {
/* if the output was a URL, generate our redirect file */
String redirectFile = "${args.artifacts}.html"
String redirectHtml = "<html><head><meta http-equiv=\"refresh\" content=\"0;url=${uploadedUrl}\" /></head><body></body></html>"
writeFile file: redirectFile, text:redirectHtml
steps.archiveArtifacts redirectFile
}
}
def call(String artifacts) {