简体   繁体   中英

Jenkins Pipeline Job Build

I am trying to build a Jenkins Pipeline job. I am trying to put sonarqube scanner configurations into Jenkins pipeline job's Groovy script. Jenkins Pipeline Job Groovy脚本中的Sonarqube配置

But when I build the above job I get the following error- 错误

Also when I refer to Sonarqube documentation for integrating with Jenkins Pipeline job I get no information about setting the sonarqube properties which otherwise we have to set by adding a step - "execute sonarqube scanner"

在此处输入图片说明

Could anyone help in knowing how can we set the Sonarqube properties in jenkins pipeline job which otherwise we can specify in Maven or Freestyle Job Types in Jnekins (shown in above snapshot). Thanks.

Now I have changes the Groovy script of Jenkins Pipeline Job configuration- 在此处输入图片说明

Now I am getting the error -

在此处输入图片说明

Could anyone please help me with the above issue.

The configuration file is, in my case, always in the application repository and then called from the jenkins job as $WORKSPACE/sonar-project.properties

The content of the file is (example):

# Required metadata
sonar.projectKey=<project-key>
sonar.projectName=<project-name>
sonar.projectVersion=<project-version>

# Comma-separated paths to directories with sources (required)
sonar.sources=src
sonar.exclusions=src/vendor/**/*

# Language
sonar.language=php

# Encoding of the source files
sonar.sourceEncoding=UTF-8

sonar.php.coverage.reportPath=src/coverage-clover.xml #change path to location of your test report
sonar.php.tests.reportPath=src/unitreport.xml  #change path to location of your test report

In Jenkins/Global tool configuration you must add a Sonarqube scanner, looks like this:

在此处输入图片说明

And in the manage Jenkins/Configure system you must add your Sonarqube server "redacted Sonarqube" configured like this:

Sonarqube配置示例

In the job itself you have:

def scannerHome = tool 'azure-tools-sonarqube'  #This is the scanner you added

withSonarQubeEnv('redacted Sonarqube') {  #This is the server you added
  sh "${scannerHome}/bin/sonar-scanner"
}

The unsupported major.minor version error happens because you are not running with Java 1.8.
Can you double the version of Java is 1.8 on all slaves including the master where Jenkins is running?
sonar-scanner requires Java 1.8 and your JAVA_HOME variable must point to that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM