diff --git a/Jenkinsfile b/Jenkinsfile index fa64cfb3a..219cf37a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,36 +1,28 @@ pipeline { agent any - environment { - NEXUS_CREDS = credentials('nexus-cred') - NEXUS_DOCKER_REPO = '54.170.162.132:8085' + + tools { + gradle '8.7' } 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('Checkstyle') { + steps{ + echo 'Running gradle checkstyle' + sh './gradlew checkstyleMain --no-daemon' } } - - stage('Docker Push') { + stage('Test') { steps { - echo 'Pushing Imgaet to docker hub' - sh 'docker push $NEXUS_DOCKER_REPO/spring-petclinic:${GIT_COMMIT}' + echo 'Running gradle test' + sh './gradlew test --no-daemon' + } + } + stage('Build') { + steps { + echo 'Running build automation' + sh './gradlew clean build -x test -x check -x checkFormat -x processTestAot --no-daemon' + archiveArtifacts artifacts: 'build/libs/*.jar' } } } diff --git a/Jenkinsfile-only-docker b/Jenkinsfile-only-docker new file mode 100644 index 000000000..fa64cfb3a --- /dev/null +++ b/Jenkinsfile-only-docker @@ -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}' + } + } + } +} \ No newline at end of file