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
68 changes: 33 additions & 35 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
properties(
[
[
$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']
],
pipelineTriggers([cron('H * * * *')]),
]
)
pipeline {
agent any
stages {
stage('checkout project') {
steps {
checkout scm
}
}

node {
def mvnHome
def scannerHome

stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'ca9b112d-19c3-491c-8e6d-23ec20cc5290', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'https://github.com/amruthapbhat/java-maven-junit-helloworld']]])

// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'Maven'
scannerHome = tool 'Sonar'
}

stage('Build') {
// Run the maven build
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean install/)
}

stage ('Sonar Analysis') {
//Running Sonar Analysis
withSonarQubeEnv {
bat(/"${scannerHome}\bin\sonar-scanner" -Dsonar.projectKey=java-maven-junit-helloworld -Dsonar.sources=. /)
}
}
stage('build') {
steps {
sh 'mvn clean package'
}
}

stage('report') {
parallel {
stage('archive') {
steps {
archiveArtifacts 'target/*.jar'
}
}

stage('junit') {
steps {
junit '**/target/surefire-reports/TEST-*.xml'
}
}

}
}

}
}
36 changes: 36 additions & 0 deletions Jenkinsfile_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
properties(
[
[
$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']
],
pipelineTriggers([cron('H * * * *')]),
]
)

node {
def mvnHome
def scannerHome

stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'ca9b112d-19c3-491c-8e6d-23ec20cc5290', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'https://github.com/amruthapbhat/java-maven-junit-helloworld']]])

// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'Maven'
scannerHome = tool 'Sonar'
}

stage('Build') {
// Run the maven build
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean install/)
}

stage ('Sonar Analysis') {
//Running Sonar Analysis
withSonarQubeEnv {
bat(/"${scannerHome}\bin\sonar-scanner" -Dsonar.projectKey=java-maven-junit-helloworld -Dsonar.sources=. /)
}
}