Created
December 18, 2016 04:40
-
-
Save evasilchenko/1e293d2dd88f45ceb7bba723e81620b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def regExMatch = /\/|\./, | |
// We are going to use the global BUILD_TAG to identify our artifact file. Sometimes the BUILD_TAG might contain unwanted | |
// characters so we are going to strip them out and replace them with dashes | |
safeBuildName = jenkins.branch.MultiBranchProject.rawDecode(env.BUILD_TAG).replaceAll(regExMatch, "-"), | |
artifactFolder = "target", | |
fullFileName = "${safeBuildName}.tar.gz", | |
// Define the final location and file name for the artifact file | |
applicationZip = "${artifactFolder}/${fullFileName}", | |
// List out all of the relative paths to your django apps which your application relies upon | |
// and leave out things which should not get deployed like tests and mocks. | |
// Don't forge to also include bin, inlude and lib folders | |
applicationDir = ["<django project>/<django app1>", | |
"<django project>/<django app2>", | |
"bin", "include", "lib"].join(" "); | |
stage ("Create artifact") { | |
node { | |
// Create a target directory if one doesn't exist yet | |
def needTargetPath = !fileExists("${artifactFolder}") | |
if (needTargetPath) { | |
sh "mkdir ${artifactFolder}" | |
} | |
// Create the gzipped tarball and archive it for future access and uses | |
sh "tar -czvf ${applicationZip} ${applicationDir}" | |
archiveArtifacts artifacts: "${applicationZip}", excludes: null, onlyIfSuccessful: true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment