Skip to content
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
87 changes: 12 additions & 75 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,83 +1,20 @@
pipeline{
agent any
tools {
maven 'Maven3.8'

}
pipeline{
agent any
tools{
maven "Maven 3.8.4"
}


stages{
stage("Checkout"){
stage("checkOut"){
steps{
echo "========Checking out code========"
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'MyGithubaccount', url: 'https://github.com/vcroshan/simple-java-maven-app.git']]])

}
post{
success{
echo "========Code checkout completed successfully========"
}
failure{
echo "========Code Checkout failed========"
}
}
}
stage ("Execute script") {
steps {
sh '''
echo "WORKSPACE: ${WORKSPACE}"
echo "Jenkins Job Name: ${JOB_NAME}"
'''
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/Madhumitha611999/simple-java-maven-app.git']]])
}
}
stage ("Build"){
steps{

sh "mvn -B -DskipTests clean package"
}
}
stage ("Test"){
stage("Build"){
steps{

sh "mvn test"
sh "mvn clean install"
}
post {
success {
junit "target/surefire-reports/**/*.xml"
}
}

}
/*stage ("sonar scanning") {
steps {
script {
def scannerHome = tool name: 'mySonarScanner';
withSonarQubeEnv("mySonarqubeServer") {
sh "${tool("mySonarScanner")}/bin/sonar-scanner \
-Dsonar.projectKey=SimpleMaven \
-Dsonar.sources=. \
-Dsonar.java.binaries=target \
-Dsonar.host.url=http://44.197.132.246:9000/ \
-Dsonar.login=12e2853ff7e7d0dd75ce2666eca6699aa3dc6d0a"
}
}
}
}*/
stage ("Upload to Nexus") {
steps {
sh "mvn -gs ${WORKSPACE}/settings.xml deploy"
}
}

}
post{
always{
echo "========always========"
}
success{
echo "========pipeline executed successfully ========"
archiveArtifacts artifacts: 'target/*.jar', followSymlinks: false
}
failure{
echo "========pipeline execution failed========"
}
}
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ you'll be creating yourself during the tutorial and the `scripts` subdirectory
contains a shell script with commands that are executed when Jenkins processes
the "Deliver" stage of your Pipeline.

#Added new comment for testing Github Webooks from Github
changes have been added

83 changes: 83 additions & 0 deletions jenkinsfile-old
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
pipeline{
agent any
tools {
maven 'Maven3.8'

}
stages{
stage("Checkout"){
steps{
echo "========Checking out code========"
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'MyGithubaccount', url: 'https://github.com/vcroshan/simple-java-maven-app.git']]])

}
post{
success{
echo "========Code checkout completed successfully========"
}
failure{
echo "========Code Checkout failed========"
}
}
}
stage ("Execute script") {
steps {
sh '''
echo "WORKSPACE: ${WORKSPACE}"
echo "Jenkins Job Name: ${JOB_NAME}"
'''
}
}
stage ("Build"){
steps{

sh "mvn -B -DskipTests clean package"
}
}
stage ("Test"){
steps{

sh "mvn test"
}
post {
success {
junit "target/surefire-reports/**/*.xml"
}
}

}
/*stage ("sonar scanning") {
steps {
script {
def scannerHome = tool name: 'mySonarScanner';
withSonarQubeEnv("mySonarqubeServer") {
sh "${tool("mySonarScanner")}/bin/sonar-scanner \
-Dsonar.projectKey=SimpleMaven \
-Dsonar.sources=. \
-Dsonar.java.binaries=target \
-Dsonar.host.url=http://44.197.132.246:9000/ \
-Dsonar.login=12e2853ff7e7d0dd75ce2666eca6699aa3dc6d0a"
}
}
}
}*/
stage ("Upload to Nexus") {
steps {
sh "mvn -gs ${WORKSPACE}/settings.xml deploy"
}
}

}
post{
always{
echo "========always========"
}
success{
echo "========pipeline executed successfully ========"
archiveArtifacts artifacts: 'target/*.jar', followSymlinks: false
}
failure{
echo "========pipeline execution failed========"
}
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<artifactId>Madhu</artifactId>
<packaging>jar</packaging>
<version>1.3-SNAPSHOT</version>
<name>my-app</name>
<name>Madhu</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
Expand Down