How to integrate an angular project's Jenkinsfile with Sonarqube

sonarqube
jenkins

(Priyal George) #1

I have an angularjs project. the project has a Jenkinsfile(declarative pipeline) which can build the jenkinsjob when a push is done. I’m trying to include a sonarqube action here for static scan. Searched a lot for angular projects with my scenario. but most of the examples i checked have pom.xml file(cause they were either java related projects).

I have written a sonar-projects.properties in root and added all necessary item:

sonar.projectKey=apols:webproject
sonar.projectName=webproject
sonar.projectVersion=1.0.0
sonar.projectDescription=Static analysis for the AppName
sonar.sources=www
sonar.exclusions=**/node_modules/**,**/*.spec.ts,**/dist/**,**/docs/**,**/*.js,**/coverage/**
sonar.tests=www 
sonar.test.inclusions=**/*.spec.ts
sonar.ts.tslint.configPath=tslint.json
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.ts.coverage.lcovReportPath=coverage/lcov.info

My Jenkinsfile’s sonar scan portion -

stage('Sonarqube') {
	 steps {
		container('maven') {
		    script {
			   withSonarQubeEnv('SonarQube') {
                  sh 'mvn clean package sonar:sonar'
			   }
			   timeout(time: 10, unit: 'MINUTES') {
		    	    waitForQualityGate abortPipeline: true
			   }
            }
		}
	 }
}

As you can see i’m using the maven container in jenkins.

When the jenkins job runs, when it executes this line in Jenkinsfile - sh 'mvn clean package sonar:sonar' , it checks for the pom.xml file and fails. So how can i point this to my sonar-projects.properties .
Please help


(Adam Gabryś) #2

(Priyal George) #3

Thanks. Was really helpful