首页 \ 问答 \ 在Jenkins 2管道内执行SonarQube扫描仪(Execute SonarQube Scanner within Jenkins 2 Pipeline)

在Jenkins 2管道内执行SonarQube扫描仪(Execute SonarQube Scanner within Jenkins 2 Pipeline)

我想在我的Jenkins 2.x Pipeline中执行“SonarQube扫描仪”步骤。

当我尝试在pipeline-syntax中创建一个示例groovy时,我只能得到以下格式的groovy脚本:

step <object of type hudson.plugins.sonar.SonarRunnerBuilder>

有谁知道什么是正确的步骤语法? 例如Publish JUnit Report看起来像

step([$class: 'JUnitResultArchiver', testResults: ''])

我使用以下版本:

  • 詹金斯2.11
  • SonarQube扫描仪2.6.1
  • SonarQube插件2.4.1

I want to execute a "SonarQube Scanner" Step within my Jenkins 2.x Pipeline.

When I try to create a sample groovy within the pipeline-syntax I only get a groovy script of the following format:

step <object of type hudson.plugins.sonar.SonarRunnerBuilder>

Does anyone know what is the correct Step Syntax? E.g. Publish JUnit Report looks like

step([$class: 'JUnitResultArchiver', testResults: ''])

I use the following Versions:

  • Jenkins 2.11
  • SonarQube Scanner 2.6.1
  • SonarQube Plugin 2.4.1

原文:https://stackoverflow.com/questions/38124171
更新时间:2022-07-21 17:07

最满意答案

在这个一般主题上有很多SO问题,根据个人偏好,可读性,紧凑性,灵活性和速度,推荐ave()aggregate()plyr()reshape2::castdata.table 。 ..这是一个简单的解决方案,使用aggregate()似乎可以做你想要的:

(aa <- aggregate(Sepal.Length~Species,data=iris,quantile))

##      Species Sepal.Length.0% Sepal.Length.25% Sepal.Length.50% Sepal.Length.75%
## 1     setosa           4.300            4.800            5.000            5.200
## 2 versicolor           4.900            5.600            5.900            6.300
## 3  virginica           4.900            6.225            6.500            6.900
##   Sepal.Length.100%
## 1             5.800
## 2             7.000
## 3             7.900

编辑 :重新阅读/基于评论,这不是您想要的:您需要为每一行复制的汇总值,而不是每组一次。

也许

merge(iris,aa,by="Species")

虽然这给出了一个奇怪的数据框(最后的“列”实际上是一个矩阵)。

这有点神奇,但是

merge(iris,with(aa,data.frame(Species,Sepal.Length)))

更好 - 它会将aggregate()返回的奇怪数据帧解压缩一点(名称仍然有点不稳定)。


There are a lot of SO questions on this general topic, recommending various uses of ave(), aggregate(), plyr(), reshape2::cast, or data.table depending on personal preference, readability, compactness, flexibility, speed ... Here's a simple solution with aggregate() that seems to do what you want:

(aa <- aggregate(Sepal.Length~Species,data=iris,quantile))

##      Species Sepal.Length.0% Sepal.Length.25% Sepal.Length.50% Sepal.Length.75%
## 1     setosa           4.300            4.800            5.000            5.200
## 2 versicolor           4.900            5.600            5.900            6.300
## 3  virginica           4.900            6.225            6.500            6.900
##   Sepal.Length.100%
## 1             5.800
## 2             7.000
## 3             7.900

edit: re-reading/based on comment, this is not what you want: you need the summarized values replicated for each row, not just once per group.

Perhaps

merge(iris,aa,by="Species")

although that gives a slightly weird data frame (the last "column" is actually a matrix).

It's a little bit magical, but

merge(iris,with(aa,data.frame(Species,Sepal.Length)))

is better -- it unpacks the weird data frame returned by aggregate() a bit more (the names are still a bit wonky).

相关问答

更多
  • 这有点微妙,我认为最好的文档实际上是在参数匹配的R语言定义中: 在函数评估中发生的第一件事是形式与实际或提供的参数的匹配。 这是通过三遍过程完成的: 标签上的精确匹配。 对于每个命名的提供参数,将搜索形式参数列表以查找其名称完全匹配的项。 使相同的形式参数匹配多个实际值是错误的,反之亦然。 标签上的部分匹配。 使用部分匹配将每个剩余的命名提供参数与剩余的正式参数进行比较。 如果提供的参数的名称与形式参数的第一部分完全匹配,则认为两个参数匹配。 具有多个部分匹配是错误的。 请注意,如果f < - functi ...
  • 我认为你可以简单地传递数组作为指针(不指向数组的指针): void function(unsigned char p[4][4], unsigned char x, unsigned char * arr) { unsigned char result; for (int ii = 0; ii < 4; ii++) { result = p[ii][1] - p[ii][2] + p[ii][0] * x + p[ii][3] * 4; arr[ii] ...
  • 在这个一般主题上有很多SO问题,根据个人偏好,可读性,紧凑性,灵活性和速度,推荐ave() , aggregate() , plyr() , reshape2::cast或data.table 。 ..这是一个简单的解决方案,使用aggregate()似乎可以做你想要的: (aa <- aggregate(Sepal.Length~Species,data=iris,quantile)) ## Species Sepal.Length.0% Sepal.Length.25% Sepal.Leng ...
  • 也许我错过了一些东西,但是这里的apply()方法可以很好地工作,不会很难看,也不需要任何丑陋的黑客。 一些虚拟数据: df <- data.frame(A = rnorm(20), B = rnorm(20), site = gl(5,4), month = gl(10, 2)) 出什么问题了: sapply(df[, c("A","B")], ave, df$site, df$month) ? 如果你真的想要的话,通过data.frame()将它强制转换为数据框。 R> sapply(df[, c( ...
  • 如果我知道你想在更高的层面上做什么,我可能会给你更好的建议。 当我读到这个问题时,我问自己:“他为什么要这么做?”。 有机会有更好的方法来做你想做的事情。 话虽如此,我认为你正在尝试做这样的事情。 function [x y] = foo x = 0; y = 0; for i = 1:100 if x(end)> [x y ...
  • R ave函数( https://stat.ethz.ch/R-manual/R-devel/library/stats/html/ave.html )将函数(默认为平均值)应用于具有相同因子水平的观察组合。 在pandas中,没有开箱即用的功能,但你可以通过groupby操作来完成。 从您的数据框开始: In [86]: df = pd.DataFrame({'A': [1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L], 'B':range(1,10)}) In [87]: df ...
  • ave适用于R 3.2.2 , R 3.1.0 (基于@ Pascal的评论)和R studio version 0.99.467 。 所以,我们不确定错误背后的真正原因。 就mean而言,我们不需要明确指定,如 ave(df$snakes, df$area) #[1] 2.75 4.50 3.50 2.75 2.75 2.75 4.50 3.50 base R替代方案是split/unsplit ,我们split “蛇” split为“区域”列,获取snakes的mean ,将其复制到list元素的le ...
  • 我不确定删除的答案是否与此相同,但您可以在几行中有效地完成。 # Simulate data set.seed(1) n<-1000 dt<-data.frame(SIC=sample(1:10,n,replace=TRUE),FYEAR=sample(2003:2007,n,replace=TRUE), AU=sample(1:7,n,replace=TRUE),AT=abs(rnorm(n))) # Cacluate proportion. dt$prop<-ave(dt$AT,dt$SIC,dt$F ...
  • 我尝试着大声修改,但发现它非常复杂,因为它需要一个数字作为参数,所以你已经发现which.max会给你带来麻烦。 你可以考虑使用data.table 。 我意识到这个输出不匹配maxAngleCORRECT,但我认为这是与关系(与t_subjNum == 2和t_trialNum == 2,最大绝对(perpdist)是5,导致60的anglediff领导。 library(data.table) setDT(df)[,maxangle:=angdiff[which.max(abs(perpdist))], ...
  • 因为你有了功能框架,所以我们必须使用它。 checkAssessment <- function(df, assessmentName) { x <- df[[assessmentName]] ## extract column vector return(list(min = min(x), max = max(x), avg = mean(x))) ## use a list for multiple return } 注意: 要通过匹配列名称(确切地)从数据框中提取列,请使用[[]] 。 使用$ ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)