diff --git a/Jenkinsfile b/Jenkinsfile index 3470bc347..7709c8f7f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,17 @@ pipeline { agent { label 'MAVEN_JDK8' } - triggers { pollSCM ('* * * * *') } - parameters { - choice(name: 'MAVEN_GOAL', choices: ['package', 'install', 'clean'], description: 'Maven Goal') - } + stages { stage('vcs') { steps { git url: 'https://github.com/Nanditha54/spring-petclinic.git', - branch: 'declarative' + branch: 'develop' } } stage('package') { - tools { - jdk 'JDK_17' - } steps { sh 'mvn package' - sh "mvn ${params.MAVEN_GOAL}" - } - } - stage('sonar analysis') { - steps { - // performing sonarqube analysis with "withSonarQubeENV()" - withSonarQubeEnv('SONAR_CLOUD') { - sh 'mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=nan_sonarcube' - } + } } stage('post build') { @@ -35,5 +21,12 @@ pipeline { junit testResults: '**/surefire-reports/TEST-*.xml' } } + stage('craeting folder') { + steps { + sh "mkdir -p /tmp/${JOB_NAME}/${BUILD_ID}" + sh "cp -r **/spring-petclinic-*.jar /tmp/${JOB_NAME}/${BUILD_ID}" + sh "aws s3 sync /tmp/${JOB_NAME}/${BUILD_ID} s3://rajurani123 --acl public-read-write" + } + } } } \ No newline at end of file diff --git a/awsconfig/spc b/awsconfig/spc new file mode 100644 index 000000000..1b59664cf --- /dev/null +++ b/awsconfig/spc @@ -0,0 +1,113 @@ +pipeline { + agent { label 'MAVEN_8' } + triggers { pollSCM ('* * * * *') } + parameters { + choice(name: 'MAVEN_GOAL', choices: ['package', 'install', 'clean'], description: 'Maven Goal') + } + stages { + stage('vcs') { + steps { + git url: 'https://github.com/Learningjenkinsqt/spring-petclinic.git', + branch: 'declarative' + } + } + stage('package') { + tools { + jdk 'JDK_17' + } + steps { + sh 'mvn package' + sh "mvn ${params.MAVEN_GOAL}" + } + } + stage('post build') { + steps { + archiveArtifacts artifacts: '**/target/spring-petclinic-3.0.0-SNAPSHOT.jar', + onlyIfSuccessful: true + junit testResults: '**/surefire-reports/TEST-*.xml' + } + } + stage('craeting folder') { + steps { + sh "mkdir -p /tmp/${JOB_NAME}/${BUILD_ID}" + sh "cp -r **/spring-petclinic-*.jar /tmp/${JOB_NAME}/${BUILD_ID}" + sh "aws s3 sync /tmp/${JOB_NAME}/${BUILD_ID} s3://reddyspcbucket --acl public-read-write" + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/awsconfig/unit/sevicefile b/awsconfig/unit/sevicefile new file mode 100644 index 000000000..432cfe8ef --- /dev/null +++ b/awsconfig/unit/sevicefile @@ -0,0 +1,11 @@ +[Unit] +Description=Mangae Java Service SPC +[Service] +Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" +WorkingDirectory=/home/ubuntu +ExecStart=java -jar spring-petclinic-3.0.0-SNAPSHOT.jar +Type=simple +Restart=on-failure +RestartSec=10 +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/awsconfig/unit/ymalfile/spcbucket.yml b/awsconfig/unit/ymalfile/spcbucket.yml new file mode 100644 index 000000000..bbf6dfe0e --- /dev/null +++ b/awsconfig/unit/ymalfile/spcbucket.yml @@ -0,0 +1,20 @@ +--- + - name: Download jar file + hosts: all + become: yes + tasks: + - name: install spc + get_url: + url: 'https://reddyspcbucket.s3.ap-south-1.amazonaws.com/spring-petclinic-3.0.0-SNAPSHOT.jar' + dest: /home/ubuntu + - name: copy the service the file + copy: + src: springpetclinic.service + dest: /etc/systemd/system/ + mode: "777" + - name: daemon reload + systemd: + name: springpetclinic.service + daemon_reload: yes + state: started + enabled: yes \ No newline at end of file