在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
最满意答案
在这个一般主题上有很多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.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
, ordata.table
depending on personal preference, readability, compactness, flexibility, speed ... Here's a simple solution withaggregate()
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 ...
-
矢量从函数返回(Vector return from a function)[2022-01-22]
我认为你可以简单地传递数组作为指针(不指向数组的指针): 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 ...
-
按列排列(R ave by columns)[2023-05-23]
也许我错过了一些东西,但是这里的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 ...
-
ave和which.max在R(ave and which.max in R)[2023-02-24]
我尝试着大声修改,但发现它非常复杂,因为它需要一个数字作为参数,所以你已经发现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))], ... -
编写一个返回矢量或三个统计数据列表的函数(Write a function that returns a vector or list of three statistics)[2021-06-23]
因为你有了功能框架,所以我们必须使用它。 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 } 注意: 要通过匹配列名称(确切地)从数据框中提取列,请使用[[]] 。 使用$ ...