MC - MediaCollector. A WebApplication for managing Records and CDs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

150 lines
3.5 KiB

//
// Jenkins file
//
// @version 2021-07-13
// @author pilgrim.lutz@imail.de
def branch = "$BRANCH_NAME"
def mcstage = getStage("$BRANCH_NAME")
def mctag = ""
def gittag = ""
def deploy = mustDeploy("$BRANCH_NAME")
def testWithDatabase = mustDeploy("$BRANCH_NAME")
def checkDependencies = mustDeploy("$BRANCH_NAME")
def mcerrormode = getStage("$BRANCH_NAME") == 'master' ? 0 : 1
def scmUrl = "${GIT_URL}/MC.git"
def getStage(branch) {
def sd = branch.split("-")
if (sd == null) {
return ""
}
return sd[0]
}
def mustDeploy(branch) {
if (branch == "master")
return true;
if (branch.startsWith("new-1-"))
return true;
if (branch.startsWith("fix-1-"))
return true;
}
pipeline {
agent any
parameters {
string(name: 'jdkbaseimage', defaultValue: 'arm32v7/openjdk', description: 'Base image for OpenJDK' )
string(name: 'jdkbasedir', defaultValue: '/usr', description: 'Base dir to find /bin/javac' )
}
stages {
stage('preparation') {
steps {
echo "------------------------------------ Preparation for stage \"${mcstage}\""
script {
mctag = sh (
script: 'git --no-pager log --format=format:%s -1',
returnStdout: true
).trim()
}
echo "latest change: \"${mctag}\"."
script {
gittag = sh (
script: 'git describe',
returnStdout: true,
returnStatus: true
)
}
echo "latest git tag: \"${gittag}\". Deploying: ${deploy}"
}
}
stage('dependency check') {
when {
expression {
return checkDependencies
}
}
steps {
echo "------------------------------------ dependency check \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew dependencyCheckAnalyze -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pmcerrormode=${mcerrormode}"
}
}
stage('assemble') {
steps {
echo "------------------------------------ Assemble for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew clean assemble -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pmcerrormode=${mcerrormode}"
}
}
stage('test') {
steps {
echo "------------------------------------ test for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew test -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pmcerrormode=${mcerrormode}"
}
}
stage('test with database') {
when {
expression {
return testWithDatabase
}
}
steps {
echo "------------------------------------ test database for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew core:testWithDatabase -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pmcerrormode=${mcerrormode}"
}
}
stage('make love') {
steps {
echo "------------------------------------ war for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew jar -Pmctag=\"${mctag}\" -Pmcstage=${mcstage}"
}
}
stage('make docker image') {
when {
expression {
return deploy
}
}
steps {
echo "------------------------------------ making docker image for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew -i makeDockerImage -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pjdkbaseimage=${params.jdkbaseimage} -Pjdkbasedir=${params.jdkbasedir}"
}
}
stage('publish docker image') {
when {
expression {
return deploy
}
}
steps {
echo "------------------------------------ publishing docker image for stage \"${mcstage}\" and tag \"${mctag}\""
sh "./gradlew -i publishDockerImage -Pmctag=\"${mctag}\" -Pmcstage=${mcstage} -Pjdkbaseimage=${params.jdkbaseimage} -Pjdkbasedir=${params.jdkbasedir}"
}
}
}
}