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

Demo 2 #151

Open
wants to merge 8 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
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM tomcat:8
LABEL app=my-app
COPY target/*.war /usr/local/tomcat/webapps/myweb.war
FROM openjdk:11-jre-slim
WORKDIR /app
COPY target/myweb-0.0.9.war /app/
CMD ["java", "-jar", "myweb-0.0.9.war"]




60 changes: 44 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
@Library("mylibs") _
pipeline {
agent any
tools {
maven 'maven2'
}
stages{
stage("Maven Build"){
steps{
sh "mvn clean package"
}
agent none

stages {
stage('git checkout') {
agent {
label "maven"
}
steps {
git 'https://github.com/artisenzubair/my-app.git'
}
}
stage('SonarQube Analysis') {
agent {
label "maven"
}
steps {
script {
withSonarQubeEnv('sonarqube') {
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) {
sh """mvn clean verify sonar:sonar \
-Dsonar.projectKey=demo \
-Dsonar.host.url=http://100.24.253.252:9000 \
-Dsonar.login=$SONARQUBE_TOKEN"""
}
}
}
}
}
stage('build') {
agent {
label "tomcat"
}
steps {
sh "mvn clean install"
}
}
stage('tomcat') {
agent {
label "tomcat"
}
steps {
sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/"
}
}
}
stage("Deploy To Dev"){
steps{
tomcatDeploy("tomcat-dev","ec2-user",["172.31.13.89","172.31.13.89"])
}
}
}
}
48 changes: 48 additions & 0 deletions jenkinsfile.declarative
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
pipeline {
agent none

stages {
stage('git checkout') {
agent {
label "maven"
}
steps {
git 'https://github.com/artisenzubair/my-app.git'
}
}
stage('SonarQube Analysis') {
agent {
label "maven"
}
steps {
script {
withSonarQubeEnv('sonarqube') {
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) {
sh """mvn clean verify sonar:sonar \
-Dsonar.projectKey=demo \
-Dsonar.host.url=http://100.24.253.252:9000 \
-Dsonar.login=$SONARQUBE_TOKEN"""
}
}
}
}
}
stage('build') {
agent {
label "tomcat"
}
steps {
sh "mvn clean install"
}
}
stage('tomcat') {
agent {
label "tomcat"
}
steps {
sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/"
}
}
}
}

33 changes: 33 additions & 0 deletions jenkinsfile.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
node {
stage('git checkout') {
// Run on an agent labeled "maven"
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/artisenzubair/my-app.git']]])

}
stage('SonarQube Analysis') {
// Run on an agent labeled "maven"
withSonarQubeEnv('sonarqube') {
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONARQUBE_TOKEN')]) {
// Run Maven and SonarQube analysis
sh """mvn clean verify sonar:sonar \
-Dsonar.projectKey=demo \
-Dsonar.host.url=http://100.24.253.252:9000 \
-Dsonar.login=$SONARQUBE_TOKEN"""
}
}
}
stage('build') {
// Run on an agent labeled "tomcat"
node('tomcat') {
// Run Maven build
sh "mvn clean install"
}
}
stage('tomcat') {
// Run on an agent labeled "tomcat"
node('tomcat') {
// Copy the WAR file to Tomcat webapps directory
sh "cp /home/ubuntu/workspace/assign/target/myweb-0.0.9.war /opt/tomcat/apache-tomcat-9.0.68/webapps/"
}
}
}
11 changes: 11 additions & 0 deletions jenkinsfile.new
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pipeline {
agent any

stages {
stage('git checkout') {
steps {
git 'https://github.com/artisenzubair/my-app.git'
}
}
}
}
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,18 @@
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>


</project>
1 change: 0 additions & 1 deletion sonar-status-check
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ node{
teamDomain: 'javahomecloud',
tokenCredentialId: 'slack-demo'
}

}