简体   繁体   English

詹金斯管道工作机会

[英]Jenkins Pipeline Job Build

I am trying to build a Jenkins Pipeline job. 我正在尝试建立Jenkins Pipeline工作。 I am trying to put sonarqube scanner configurations into Jenkins pipeline job's Groovy script. 我试图将声纳扫描仪配置放入Jenkins管道作业的Groovy脚本中。 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" 另外,当我参考Sonarqube文档与Jenkins Pipeline作业集成时,我没有得到有关设置声纳属性的信息,否则我们必须通过添加一个步骤来设置声纳属性-“执行声纳扫描仪”

在此处输入图片说明

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). 任何人都可以帮助我们了解如何在jenkins管道作业中设置Sonarqube属性,否则我们可以在Jnekins的Maven或Freestyle作业类型中指定(如上快照所示)。 Thanks. 谢谢。

Now I have changes the Groovy script of Jenkins Pipeline Job configuration- 现在,我更改了Jenkins Pipeline Job配置的Groovy脚本- 在此处输入图片说明

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 在我的情况下,配置文件始终在应用程序存储库中,然后从jenkins作业中调用为$ 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: 在Jenkins / Global工具配置中,您必须添加Sonarqube扫描仪,如下所示:

在此处输入图片说明

And in the manage Jenkins/Configure system you must add your Sonarqube server "redacted Sonarqube" configured like this: 在管理Jenkins / Configure系统中,您必须添加Sonarqube服务器“编辑过的Sonarqube”,其配置如下:

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. 发生unsupported major.minor version错误是因为您未在Java 1.8上运行。
Can you double the version of Java is 1.8 on all slaves including the master where Jenkins is running? 您能在所有从属服务器(包括运行Jenkins的主服务器)上将Java版本为1.8翻倍吗?
sonar-scanner requires Java 1.8 and your JAVA_HOME variable must point to that. sonar-scanner需要Java 1.8,并且您的JAVA_HOME变量必须指向该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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