diff --git a/Jenkinsfile b/Jenkinsfile index ebcccc1739..5f2ada9669 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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========" } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index fe66be00c2..6002c9f582 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/jenkinsfile-old b/jenkinsfile-old new file mode 100644 index 0000000000..ebcccc1739 --- /dev/null +++ b/jenkinsfile-old @@ -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========" + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index c9e11e7898..ee0071b448 100644 --- a/pom.xml +++ b/pom.xml @@ -2,10 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.mycompany.app - my-app + Madhu jar 1.3-SNAPSHOT - my-app + Madhu http://maven.apache.org