diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..033a524b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent any + environment { + PATH = "/opt/maven/bin:$PATH" + } + stages { + stage('Build') { + steps { + sh 'mvn clean install' + } + } + + stage('SonarQube Analysis') { + environment { + scannerHome = tool 'bharath-sonarqube-scanner' + } + steps { + withSonarQubeEnv('Bharath-SonarQube-Server') { + sh "${scannerHome}/bin/sonar-scanner" + } + } + } + + stage('Quality Gate') { + steps { + script { + timeout(time: 1, unit: 'hours') { // Corrected 'Hours' -> 'hours' + def qg = waitForQualityGate() // Fixed function name + if (qg.status != 'OK') { // Ensure 'OK' is capitalized correctly + error "Pipeline aborted due to Quality Gate failure: ${qg.status}" + } + } + } + } + } + } +} diff --git a/README.md b/README.md index 8d7640e7..086dce42 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # sparkjava-war-example Build war with maven and sparkjava framework -Steps: +Steps:- 1. Download a fresh [Tomcat 8 distribution](https://tomcat.apache.org/download-80.cgi) 2. Clone this repository to your local machine diff --git a/pom.xml b/pom.xml index f55768d8..367eeb27 100644 --- a/pom.xml +++ b/pom.xml @@ -57,4 +57,4 @@ - \ No newline at end of file + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..5ab2bead --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,22 @@ +# Required metadata +sonar.verbose=true +sonar.organization=bharathkumars-key +sonar.projectKey=bharathkumars-key_bharathtrend +sonar.projectName=bharathtrend +sonar.projectVersion=1.0 + +# Path settings +sonar.sources=src +#sonar.tests=tests +sonar.language=java +sonar.java.binaries=target/classes + +# Optional settings +sonar.sourceEncoding=UTF-8 +#sonar.exclusions=**/*.json,**/*.xml +sonar.test.inclusions=**/*Test.java + +# Coverage (if using Jacoco) +#sonar.jacoco.reportPaths=target/jacoco.exec +sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml +