mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 23:05:50 +00:00
Create Jenkinsfile
Added Jenkinsfile
This commit is contained in:
parent
3e9697795b
commit
186225040c
1 changed files with 84 additions and 0 deletions
84
Jenkinsfile
vendored
Normal file
84
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
try {
|
||||
def appName=env.APP_NAME
|
||||
def gitSourceUrl=env.GIT_SOURCE_URL
|
||||
def gitSourceRef=env.GIT_SOURCE_REF
|
||||
def project=""
|
||||
def projectVersion=""
|
||||
node("maven") {
|
||||
stage("Initialize") {
|
||||
project = env.PROJECT_NAME
|
||||
echo "appName: ${appName}"
|
||||
echo "gitSourceUrl: ${gitSourceUrl}"
|
||||
echo "gitSourceRef: ${gitSourceRef}"
|
||||
}
|
||||
stage("Checkout") {
|
||||
echo "Checkout source."
|
||||
git url: "${gitSourceUrl}", branch: "${gitSourceRef}"
|
||||
echo "Read POM info."
|
||||
pom = readMavenPom file: 'pom.xml'
|
||||
projectVersion = pom.version
|
||||
}
|
||||
stage("Build JAR") {
|
||||
echo "Build the app."
|
||||
sh "mvn clean package"
|
||||
}
|
||||
stage("Quality Check") {
|
||||
sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=false"
|
||||
sh "mvn sonar:sonar -Dsonar.jacoco.reportPaths=target/coverage-reports/jacoco-unit.exec -Dsonar.host.url=http://sonarqube.cicd.svc:9000"
|
||||
// sh "mvn org.cyclonedx:cyclonedx-maven-plugin:makeBom"
|
||||
//dependencyTrackPublisher(artifact: 'target/bom.xml', artifactType: 'bom', projectName: "${appName}", projectVersion: "${projectVersion}", synchronous: false)
|
||||
}
|
||||
stage("Build Image") {
|
||||
echo "Build container image."
|
||||
// unstash name:"jar"
|
||||
openshift.withCluster() {
|
||||
openshift.withProject('cicd') {
|
||||
sh "oc start-build ${appName}-build --from-file=target/app.jar -n cicd --follow"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Tag DEV") {
|
||||
echo "Tag image to DEV"
|
||||
openshift.withCluster() {
|
||||
openshift.withProject('cicd') {
|
||||
openshift.tag("${appName}:latest", "${appName}:dev")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Deploy DEV") {
|
||||
echo "Deploy to DEV."
|
||||
openshift.withCluster() {
|
||||
openshift.withProject("${appName}-dev") {
|
||||
echo "Rolling out to DEV."
|
||||
def dc = openshift.selector('dc', "${appName}")
|
||||
dc.rollout().latest()
|
||||
dc.rollout().status()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Tag for QA") {
|
||||
echo "Tag to UAT"
|
||||
openshift.withCluster() {
|
||||
openshift.withProject('cicd') {
|
||||
openshift.tag("${appName}:dev", "${appName}:qa")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Deploy QA") {
|
||||
echo "Deploy to QA"
|
||||
openshift.withCluster() {
|
||||
openshift.withProject("${appName}-uat") {
|
||||
echo "Rollout to QA."
|
||||
def dc = openshift.selector('dc', "${appName}")
|
||||
dc.rollout().latest()
|
||||
dc.rollout().status()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
echo "in catch block"
|
||||
echo "Caught: ${err}"
|
||||
currentBuild.result = 'FAILURE'
|
||||
throw err
|
||||
}
|
Loading…
Reference in a new issue