Skip to content
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

Dev #1

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e2cc38a
Create Jenkinsfile
akash64574 Oct 29, 2021
0395623
Update Jenkinsfile
akash64574 Oct 29, 2021
5cf1507
Update Jenkinsfile
akash64574 Oct 29, 2021
766c69b
Update Jenkinsfile
akash64574 Oct 29, 2021
8176adb
Update Jenkinsfile
akash64574 Oct 29, 2021
69d76e2
Update Jenkinsfile
akash64574 Oct 29, 2021
621d2a6
Update AppTest.java
akash64574 Oct 29, 2021
0e1c997
Update pom.xml
akash64574 Oct 29, 2021
965a008
Create Test.xml
akash64574 Oct 29, 2021
37ce9f2
Create Testing.xml
akash64574 Oct 29, 2021
46ab80f
Delete Testing.xml
akash64574 Oct 29, 2021
706ac23
Merge pull request #1 from akash64574/Dev
akash64574 Oct 29, 2021
37d07b6
Update pom.xml
akash64574 Oct 29, 2021
7bb214b
Create pom.xml
akash64574 Oct 29, 2021
d346ddc
Update AppTest.java
akash64574 Oct 29, 2021
d3901eb
Update pom.xml
akash64574 Oct 29, 2021
125ac71
Update pom.xml
akash64574 Oct 29, 2021
9d5c6c2
Merge branch 'master' into Dev
akash64574 Oct 29, 2021
815e553
Merge pull request #2 from akash64574/Dev
akash64574 Oct 29, 2021
58ebb80
Update pom.xml
akash64574 Oct 29, 2021
64af0f4
Merge pull request #3 from akash64574/Dev
akash64574 Oct 29, 2021
e4975be
Update Jenkinsfile
akash64574 Oct 31, 2021
3eb1eb2
Update Jenkinsfile
akash64574 Oct 31, 2021
e4654c3
Update Jenkinsfile
akash64574 Oct 31, 2021
9f6e757
Update Jenkinsfile
akash64574 Oct 31, 2021
55e5acf
Update Jenkinsfile
akash64574 Oct 31, 2021
12433b2
Merge branch 'master' into Dev
akash64574 Oct 31, 2021
779c6e1
Update Jenkinsfile
akash64574 Oct 31, 2021
2e1f669
update jenkins file to check webhook
akash64574 Oct 31, 2021
360f885
to check webhook
akash64574 Oct 31, 2021
1936132
Update Jenkinsfile
akash64574 Nov 1, 2021
78df023
Update Jenkinsfile
akash64574 Nov 1, 2021
5b922e7
Update Jenkinsfile
akash64574 Nov 1, 2021
80787c1
Update Jenkinsfile
akash64574 Nov 1, 2021
b95dd5a
Update Jenkinsfile
akash64574 Nov 1, 2021
286ec71
Update Dockerfile
akash64574 Nov 1, 2021
4b15c5b
Update Dockerfile
akash64574 Nov 1, 2021
3a29b03
Update Jenkinsfile
akash64574 Nov 1, 2021
0cf297e
Update Jenkinsfile
akash64574 Nov 1, 2021
95ce2d3
Update Jenkinsfile
akash64574 Nov 1, 2021
33db787
Update Jenkinsfile
akash64574 Nov 1, 2021
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
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk
COPY target/*.jar /
EXPOSE 8080
ENTRYPOINT ["java","-jar","/my-app-1.0-SNAPSHOT.jar"]
COPY target/*.jar .
EXPOSE 9000
ENTRYPOINT ["java","-cp","/my-app-1.0-SNAPSHOT.jar","com.mycompany.app.App"]
132 changes: 132 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
pipeline {
// environment {
//registry = "akash64574/myapp"
//registryCredential = 'dockerhub'
//dockerImage = ''
// }
agent any

stages {

stage('SCM Checkout') {
steps {
checkout scm
// git 'https://github.com/akash64574/maven-hello-world'
}
}

stage('Build') {
steps {
sh"/opt/maven/bin/mvn clean package "
}
}
stage("build & SonarQube analysis") {

steps {
withSonarQubeEnv('sonar') {
sh '/opt/maven/bin/mvn sonar:sonar'
}
}
}
//stage("Quality Gate") {
//steps {
//timeout(time: 1, unit: 'MINUTES') {
//waitForQualityGate abortPipeline: true
//}
//}
//}


stage("testing") {
when {
branch 'QA'
}
steps {

sh '/opt/maven/bin/mvn cobertura:cobertura -Pmetrics -Dcobertura.report.format=xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/target/site/cobertura/coverage.xml', conditionalCoverageTargets: '70, 0, 0', enableNewApi: true, failNoReports: false, failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
sh '/opt/maven/bin/mvn verify'
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/*.xml'
}
}
stage ('Notify Dev'){
steps {
slackSend baseUrl: 'https://hooks.slack.com/services/', channel: 'jenkins_dev', message: 'Build and Testing completed Deployment is under process , please wait for further notification ', teamDomain: '$WORKSPACE', tokenCredentialId: 'slack', username: 'Akash'
}
}
stage('Build Docker Image') {
steps {
script {
sh 'docker build -t akash64574/my-app-1.0 .'
}
}
}
stage ('Notify qa'){
steps {
slackSend baseUrl: 'https://hooks.slack.com/services/', channel: 'jenkins_qa', message: 'Build and Testing completed and status is good , Deployment is pending for approval', teamDomain: '$WORKSPACE', tokenCredentialId: 'slackqa', username: 'Akash'
}
}
stage( 'Appoval mail for QA' ){
steps{
slackSend baseUrl: 'https://hooks.slack.com/services/', channel: 'jenkins_qa', message: "${env.BUILD_URL}", teamDomain: '', tokenCredentialId: 'slackqa'
}
}

stage("QA Approval") {
steps {

script {
def userInput = input(id: 'Proceed1', message: 'Promote build?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']])
echo 'userInput: ' + userInput

if(userInput == true) {
// do action
} else {
// not do action
echo "Action was aborted."
}

}

}
}
stage('Push Docker Image') {
steps {
script {
withCredentials([string(credentialsId: 'dockerhub-pwd', variable: 'dockerhubpwd')]) {
sh 'docker login -u akash64574 -p ${dockerhubpwd}'
}
sh 'docker push akash64574/my-app-1.0'
}
}
}
stage ('Notify Dev again'){
steps {
slackSend baseUrl: 'https://hooks.slack.com/services/', channel: 'jenkins_dev', message: 'Your Deployment is completed :-)', teamDomain: '$WORKSPACE', tokenCredentialId: 'slack', username: 'Akash'
}
}
stage ('Notify qa again'){
when {
branch 'QA'
}
steps {
slackSend baseUrl: 'https://hooks.slack.com/services/', channel: 'jenkins_qa', message: 'Your Deployment is successfully completed !!', teamDomain: '$WORKSPACE', tokenCredentialId: 'slackqa', username: 'Akash'
}
}
stage ('email notification'){
when {
branch 'Dev'
}
steps {

emailext body: '''Hi Dev Team
Your deployment is successful !!
Regards
QA Team ''', subject: 'Jenkins Job status', to: '[email protected]'

}
}


}
}
7 changes: 7 additions & 0 deletions Test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<suite name="Testing">
<test name="Selenium QA testing">
<classes>
<class name="com.mycompany.app.AppTest"></class>
</classes>
</test>
</suite>
7 changes: 6 additions & 1 deletion src/test/java/com/mycompany/app/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class AppTest
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );

//comment the above 2 lines and uncomment below 2 lines to use Chrome
//System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe");


assertTrue( true );
}
}