Created
July 6, 2017 17:26
-
-
Save thadguidry/a69e133c1749d9e82d75071b124ed225 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
#!groovy | |
// Jenkins job parameters: | |
// BRANCH | |
node { | |
def server = Artifactory.server "Artifactory_DC1" | |
def rtGradle = Artifactory.newGradleBuild() | |
def buildInfo = Artifactory.newBuildInfo() | |
buildInfo.env.capture = true | |
def GIT_REPO="cacpl-ebi-dbscripts" | |
def GIT_BRANCH="" | |
def SNAPSHOT="" | |
def GERRIT_REFNAME = params?.GERRIT_REFNAME?.trim() | |
if (GERRIT_REFNAME) { | |
// either a master integration or release build, use gerrit trigger parameters | |
println " using GERRIT TRIGGER to run job ..." | |
GIT_BRANCH="${GERRIT_REFNAME}" | |
SNAPSHOT="" | |
} else { | |
// snapshot build, use Jenkins job parameters | |
println " using SNAPSHOT to run job ..." | |
GIT_BRANCH="${BRANCH}" | |
SNAPSHOT="-Psnapshot" | |
} | |
println "\n====================\nGIT_REPO=${GIT_REPO}\nGIT_BRANCH=${GIT_BRANCH}\nSNAPSHOT=${SNAPSHOT}\n" | |
sh "rm -f ${WORKSPACE}/env.properties; /project/scripts/flowdock-token-lookup/flowdock-token-lookup.rb" | |
//load "${WORKSPACE}/env.properties" | |
sh "rm -f ${WORKSPACE}/build.properties; /project/scripts/build-number-lookup/build-number-lookup.rb" | |
//load "${WORKSPACE}/build.properties" | |
stage('Clone sources') { | |
git clean: true, branch: "${GIT_BRANCH}", credentialsId: "${CI_CREDS}", url: "ssh://${CI_USER}@gerrit.ericsson.se:29418/cacpl/${GIT_REPO}", relativeTargetDir: "${GIT_REPO}" | |
} | |
stage('Gradle build') { | |
// SNAPSHOT variable is set by the snapshot Jenkins job with hidden parameter: -Psnapshot | |
sh "./gradlew ${SNAPSHOT}" | |
} | |
stage('Artifactory Upload') { | |
// the files pattern is a format of [repository name]/[repository path] | |
// as stated in the Artifactory Plugin docs. | |
// We use * at the beginning to wildcard the repository name, | |
// so that we can just deal with the path portion only for now. | |
// The final built package is a TAR file. | |
def uploadSpec = """{ | |
"files": [ | |
{ | |
"pattern": "build/distributions/ebidb-(*.SNAPSHOT).tar", | |
"target": "proj-attpps-dev-local/applications/ebidb/{1}/" | |
}, | |
{ | |
"pattern": "build/distributions/ebidb-(*.INT).tar", | |
"target": "proj-attpps-staging-local/applications/ebidb/{1}/" | |
}, | |
{ | |
"pattern": "build/distributions/ebidb-(\\d+\\.\\d+\\.0)\\.tar", | |
"regexp": "true", | |
"target": "proj-attpps-release-local/applications/ebidb/{1}/" | |
}, | |
{ | |
"pattern": "build/distributions/(\\d+\\.\\d+\\.0)/.*.tar.gz", | |
"regexp": "true", | |
"target": "proj-attpps-release-local/applications/ebidb/{1}/" | |
} | |
] | |
}""" | |
server.upload(uploadSpec, buildInfo) | |
server.publishBuildInfo(buildInfo) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment