mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 08:15:49 +00:00
Jenkinfile for building app
This commit is contained in:
parent
7c2abe3585
commit
1e1ad4073b
2 changed files with 54 additions and 25 deletions
40
Jenkinsfile
vendored
40
Jenkinsfile
vendored
|
@ -1,36 +1,28 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
|
||||||
NEXUS_CREDS = credentials('nexus-cred')
|
tools {
|
||||||
NEXUS_DOCKER_REPO = '54.170.162.132:8085'
|
gradle '8.7'
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
stage('Checkstyle') {
|
||||||
stage('Docker Build') {
|
steps{
|
||||||
|
echo 'Running gradle checkstyle'
|
||||||
|
sh './gradlew checkstyleMain --no-daemon'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Test') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Building docker Image'
|
echo 'Running gradle test'
|
||||||
sh 'docker build -t $NEXUS_DOCKER_REPO/spring-petclinic:${GIT_COMMIT} .'
|
sh './gradlew test --no-daemon'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Build') {
|
||||||
stage('Docker Login') {
|
|
||||||
steps {
|
steps {
|
||||||
echo 'Nexus Docker Repository Login'
|
echo 'Running build automation'
|
||||||
script{
|
sh './gradlew clean build -x test -x check -x checkFormat -x processTestAot --no-daemon'
|
||||||
withCredentials([usernamePassword(credentialsId: 'nexus-cred', usernameVariable: 'USER', passwordVariable: 'PASS' )]){
|
archiveArtifacts artifacts: 'build/libs/*.jar'
|
||||||
sh ' echo $PASS | docker login -u $USER --password-stdin $NEXUS_DOCKER_REPO'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Docker Push') {
|
|
||||||
steps {
|
|
||||||
echo 'Pushing Imgaet to docker hub'
|
|
||||||
sh 'docker push $NEXUS_DOCKER_REPO/spring-petclinic:${GIT_COMMIT}'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
37
Jenkinsfile-only-docker
Normal file
37
Jenkinsfile-only-docker
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
environment {
|
||||||
|
NEXUS_CREDS = credentials('nexus-cred')
|
||||||
|
NEXUS_DOCKER_REPO = '54.170.162.132:8085'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage('Docker Build') {
|
||||||
|
|
||||||
|
steps {
|
||||||
|
echo 'Building docker Image'
|
||||||
|
sh 'docker build -t $NEXUS_DOCKER_REPO/spring-petclinic:${GIT_COMMIT} .'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Docker Login') {
|
||||||
|
steps {
|
||||||
|
echo 'Nexus Docker Repository Login'
|
||||||
|
script{
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'nexus-cred', usernameVariable: 'USER', passwordVariable: 'PASS' )]){
|
||||||
|
sh ' echo $PASS | docker login -u $USER --password-stdin $NEXUS_DOCKER_REPO'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Docker Push') {
|
||||||
|
steps {
|
||||||
|
echo 'Pushing Imgaet to docker hub'
|
||||||
|
sh 'docker push $NEXUS_DOCKER_REPO/spring-petclinic:${GIT_COMMIT}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue