This commit is contained in:
Madhuri-chinta 2023-03-15 06:09:23 +00:00 committed by GitHub
commit f1fa5cff36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 170 additions and 0 deletions

70
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,70 @@
pipeline {
agent { label 'UBUNTU_NODE1' }
triggers { pollSCM('* * * * *') }
stages {
stage('get url') {
steps {
git branch: 'sweety',
url: 'https://github.com/Madhuri-chinta/spring-petclinic.git'
}
}
stage('package') {
steps {
sh './mvnw package'
}
}
stage('sonarqube') {
steps {
withSonarQubeEnv('madhuri') {
sh 'mvn clean package sonar:sonar'
}
}
}
stage('artifactory') {
steps {
rtMavenDeployer (
id: "jfrog",
serverId: "madhuri",
releaseRepo: "madhuri",
snapshotRepo: "madhuri"
)
}
}
stage ('Exec Maven') {
steps {
rtMavenRun (
tool: "MAVEN_GOAL", // Tool name from Jenkins configuration
pom: 'pom.xml',
goals: 'clean install',
deployerId: "jfrog"
)
}
}
stage ('Publish build info') {
steps {
rtPublishBuildInfo (
serverId: "madhuri"
)
}
}
stage('post build') {
steps {
archiveArtifacts artifacts: '**/target/*.jar',
onlyIfSuccessful: true
junit testResults: '**/surefire-reports/TEST-*.xml'
}
}
stage('deploy') {
agent any
steps {
sh 'ansible -i ./ansible/hosts -m ping all'
sh 'ansible-playbook -i ./ansible/hosts ./ansible/spc.yaml'
}
}
}
}

1
ansible/hosts Normal file
View file

@ -0,0 +1 @@
172.31.15.26

11
ansible/madhuri.service Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=my springpetclinic application
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu
ExecStart=/usr/lib/jvm/java-17-openjdk-amd64/bin/java -jar /home/ubuntu/spring-petclinic-3.0.0-20230314.161709-3.jar
Restart=always
[Install]
WantedBy=multi-user.target

28
ansible/spc.yaml Normal file
View file

@ -0,0 +1,28 @@
---
- name: install springpetclinic
hosts: all
become: yes
tasks:
- name: install java17 and maven
ansible.builtin.apt:
name:
- openjdk-17-jdk
- maven
state: present
update_cache: yes
- name: get url from s3 bucket
ansible.builtin.get_url:
url: https://akshara1413.s3.ap-south-1.amazonaws.com/spring-petclinic-3.0.0-20230314.161709-3.jar
dest: /home/ubuntu
- name: copy service file
ansible.builtin.copy:
src: ./madhuri.service
dest: /etc/systemd/system/spring.service
- name: deamon-reload service
ansible.builtin.systemd:
state: started
daemon_reload: true
enabled: true
name: spring.service

11
azure-pipelines-1.yml Normal file
View file

@ -0,0 +1,11 @@
---
pool:
name: Default
trigger:
- main
steps:
- script: echo $(Build.ArtifactStagingDirectory)

27
azure-pipelines.yaml Normal file
View file

@ -0,0 +1,27 @@
---
pool:
name: default
trigger:
- main
steps:
- task: Maven@3
inputs:
mavenPOMFile: 'pom.xml'
publishJUnitResults: true
goals: 'package'
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'Path'
jdkDirectory: /usr/lib/jvm/java-17-openjdk-amd64
mavenVersionOption: 'path'
mavenDirectory: /home/ubuntu/spring-petclinic
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.Repository.LocalPath)'
ArtifactName: 'drop'
publishLocation: 'Container'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '/home/ubuntu/spc'
- script: ansible-playbook -i host spc1.yaml

22
azure-pipelines.yml Normal file
View file

@ -0,0 +1,22 @@
pool:
name: "Azure Pipelines"
vmImage: "ubuntu-22.04"
trigger:
- main
jobs:
- job: "gradle"
displayName: "gradle job"
steps:
- task: Gradle@3
inputs:
gradleWrapperFile: 'gradlew'
workingDirectory: '$(Build.Repository.LocalPath)'
tasks: 'build'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false