Skip to content

updated my jenkins please mergit #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pipeline{
agent {
label 'docker'
}
stages{
stage("build stage"){
steps{
sh "mvn clean install"
}
}
stage("build test"){
steps{
sh "mvn test"
}
}
stage("sonarqube"){
steps{
withSonarQubeEnv(credentialsId: 'sonar') {
sh "mvn clean verify sonar:sonar"
}
}
}
}
}
51 changes: 51 additions & 0 deletions Jenkinsfile1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pipeline{
agent any
environment{
registry = '399747338321.dkr.ecr.ap-south-1.amazonaws.com/onlinebookstoreappdeploy'
imagename = 'onlineapp'
}
stages{
stage('Build mvn packages'){
steps{
sh 'mvn clean install'

}
}
stage('test packages'){
steps{
sh 'mvn test'
}
}
stage('build docker image'){
steps{
sh 'docker build -t onlinebookstoreappdeploy:${BUILD_NUMBER} .'
}
}
stage('login docker'){
steps{
sh 'aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 399747338321.dkr.ecr.ap-south-1.amazonaws.com'
}
}
stage('tag image'){
steps{
sh 'docker tag onlinebookstoreappdeploy:${BUILD_NUMBER} 399747338321.dkr.ecr.ap-south-1.amazonaws.com/onlinebookstoreappdeploy:${BUILD_NUMBER}'
}
}
stage('Push image to registry'){
steps{
sh 'docker push 399747338321.dkr.ecr.ap-south-1.amazonaws.com/onlinebookstoreappdeploy:${BUILD_NUMBER}'
}
}
stage('stop pervious container'){
steps{
sh 'docker ps -f name=${imagename} -q | xargs --no-run-if-empty docker container stop'
sh 'docker container ls -a -fname=${imagename} -q | xargs -r docker container rm'
}
}
stage('Image,run as container'){
steps{
sh 'docker run -itd --name ${imagename} -p 8083:8080 399747338321.dkr.ecr.ap-south-1.amazonaws.com/onlinebookstoreappdeploy:${BUILD_NUMBER}'
}
}
}
}
22 changes: 22 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
vmImage: ubuntu-latest

steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
7 changes: 7 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM tomcat

COPY target/shopping-cart-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/

EXPOSE 8083

CMD ["catalina.sh", "run"]
2 changes: 1 addition & 1 deletion src/application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Database Credentials
db.driverName = com.mysql.cj.jdbc.Driver
db.connectionString = jdbc:mysql://localhost:3306/shopping-cart
db.connectionString = jdbc:mysql://mysql:3306/shopping-cart
db.username = root
db.password = root

Expand Down
1 change: 1 addition & 0 deletions token.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqp_0de1412e055ed2aa7ea236e9eec04fec9cbeacd4