added s3bucket

This commit is contained in:
Nanditha54 2023-03-16 06:36:57 +05:30
parent 949f5af92d
commit 423c711534
4 changed files with 154 additions and 17 deletions

27
Jenkinsfile vendored
View file

@ -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(<Name of Server configured in Jenkins>)"
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"
}
}
}
}

113
awsconfig/spc Normal file
View file

@ -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"
}
}

11
awsconfig/unit/sevicefile Normal file
View file

@ -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

View file

@ -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