diff --git a/Jenkinsfile b/Jenkinsfile index 568fdb9..06967e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,88 +1,35 @@ pipeline { - triggers { - pollSCM('* * * * *') - } - agent any + agent any tools { - maven 'M2_HOME' -} -environment { - registry = '076892551558.dkr.ecr.us-east-1.amazonaws.com/jenkins' - registryCredential = 'jenkins-ecr' - dockerimage = '' - - NEXUS_VERSION = "nexus3" - NEXUS_PROTOCOL = "http" - NEXUS_URL = "139.177.192.139:8081" - NEXUS_REPOSITORY = "utrains-nexus-pipeline" - NEXUS_CREDENTIAL_ID = "nexus-user-credentials" - POM_VERSION = '' -} + maven 'M2_HOME' + } stages { - - stage("build & SonarQube analysis") { - steps { - echo 'build & SonarQube analysis...' - withSonarQubeEnv('SonarServer') { - sh 'mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=kserge2001_geolocation -X' - } - } - } - stage('Check Quality Gate') { - steps { - echo 'Checking quality gate...' - script { - timeout(time: 20, unit: 'MINUTES') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline stopped because of quality gate status: ${qg.status}" - } - } - } - } - } - - - stage('maven package') { - steps { - sh 'mvn clean' - sh 'mvn package -DskipTests' - } - } - stage('Build Image') { - - steps { - script{ - def mavenPom = readMavenPom file: 'pom.xml' - POM_VERSION = "${mavenPom.version}" - echo "${POM_VERSION}" - dockerImage = docker.build registry + ":${POM_VERSION}" - } - } - } - stage('push image') { + stage("maven build") { steps{ - script{ - docker.withRegistry("https://"+registry,"ecr:us-east-1:"+registryCredential) { - dockerImage.push() - } - } + sh 'mvn clean install package' } - } - // Project Helm Chart push as tgz file - stage("pushing the Backend helm charts to nexus"){ + } + stage("upload artifact") { steps{ script{ - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'nexus-pass', usernameVariable: 'jenkins-user', passwordVariable: 'docker_pass']]) { - def mavenPom = readMavenPom file: 'pom.xml' - POM_VERSION = "${mavenPom.version}" - sh "echo ${POM_VERSION}" - sh "tar -czvf app-${POM_VERSION}.tgz app/" - sh "curl -u jenkins-user:$docker_pass http://139.177.192.139:8081/repository/geolocation/ --upload-file app-${POM_VERSION}.tgz -v" - } - } + def mavenPom = readMavenPom file: 'pom.xml' + nexusArtifactUploader artifacts: + [[artifactId: "${mavenPom.artifactid}", + classifier: '', + file: "target/${mavenPom.artifactid}-${mavenPom.version}.${mavenPom.packaging}", + type: "${mavenPom.packaging}"]], + credentialsId: 'Nexusid', + groupId: "${mavenPom.groupid}", + nexusUrl: '69.164.206.106:8081', + nexusVersion: 'nexus3', + protocol: 'http', + repository: 'Biomedical', + version: "${mavenPom.version}" + } } - } + + } + } -} +} \ No newline at end of file diff --git a/Jenkinsfile_bckup b/Jenkinsfile_bckup new file mode 100644 index 0000000..568fdb9 --- /dev/null +++ b/Jenkinsfile_bckup @@ -0,0 +1,88 @@ +pipeline { + triggers { + pollSCM('* * * * *') + } + agent any + tools { + maven 'M2_HOME' +} +environment { + registry = '076892551558.dkr.ecr.us-east-1.amazonaws.com/jenkins' + registryCredential = 'jenkins-ecr' + dockerimage = '' + + NEXUS_VERSION = "nexus3" + NEXUS_PROTOCOL = "http" + NEXUS_URL = "139.177.192.139:8081" + NEXUS_REPOSITORY = "utrains-nexus-pipeline" + NEXUS_CREDENTIAL_ID = "nexus-user-credentials" + POM_VERSION = '' +} + stages { + + stage("build & SonarQube analysis") { + steps { + echo 'build & SonarQube analysis...' + withSonarQubeEnv('SonarServer') { + sh 'mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=kserge2001_geolocation -X' + } + } + } + stage('Check Quality Gate') { + steps { + echo 'Checking quality gate...' + script { + timeout(time: 20, unit: 'MINUTES') { + def qg = waitForQualityGate() + if (qg.status != 'OK') { + error "Pipeline stopped because of quality gate status: ${qg.status}" + } + } + } + } + } + + + stage('maven package') { + steps { + sh 'mvn clean' + sh 'mvn package -DskipTests' + } + } + stage('Build Image') { + + steps { + script{ + def mavenPom = readMavenPom file: 'pom.xml' + POM_VERSION = "${mavenPom.version}" + echo "${POM_VERSION}" + dockerImage = docker.build registry + ":${POM_VERSION}" + } + } + } + stage('push image') { + steps{ + script{ + docker.withRegistry("https://"+registry,"ecr:us-east-1:"+registryCredential) { + dockerImage.push() + } + } + } + } + + // Project Helm Chart push as tgz file + stage("pushing the Backend helm charts to nexus"){ + steps{ + script{ + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'nexus-pass', usernameVariable: 'jenkins-user', passwordVariable: 'docker_pass']]) { + def mavenPom = readMavenPom file: 'pom.xml' + POM_VERSION = "${mavenPom.version}" + sh "echo ${POM_VERSION}" + sh "tar -czvf app-${POM_VERSION}.tgz app/" + sh "curl -u jenkins-user:$docker_pass http://139.177.192.139:8081/repository/geolocation/ --upload-file app-${POM_VERSION}.tgz -v" + } + } + } + } + } +} diff --git a/README.md b/README.md index de3dd54..2e5f6a0 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,4 @@ fdfdfghfjj Project to locate patients in order to facilitate their home appointments by medical specialists haVDGHAVJCXHSJAVC jhgvfkjghcvgc +cnvmvmfmvmcmv diff --git a/pom.xml b/pom.xml index 6ad27ba..8b7cc27 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,12 @@ com.spring bioMedical - 0.0.7-RELEASE + 0.0.5-RELEASE bioMedical Demo project for Spring Boot jar - 1.8 + 11 geolocation https://sonarcloud.io