jenkins管道脚本中出现错误。该错误表明groovy.lang.MissingMethodException:方法的无签名:org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getExecutor()适用于参数类型:()值:[]
我正在尝试将詹金斯和grafana集成在一起
stage('Grafana Results') {
// grafana url for aggregate dashboard - replace time stamp with %s
def perfResult = "<grafana url>?orgId=39&from=%s&to=%s"
// get build start and end time
def start = currentBuild.getStartTimeInMillis();
def end = start + currentBuild.getExecutor().getElapsedTime();
// replace time
perfResult = String.format(perfResult, start, end);
//build the string to be added as description.
def link = "<a href='%s'>%s</a><br/>";
def sb = new StringBuilder();
sb.append(String.format(link, perfResult, "Grafana Performance Result"));
// set build description
currentBuild.setDescription(sb.toString());
}
答案 0 :(得分:0)
首先-您必须阅读错误。有一个答案:
没有方法签名:
org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getExecutor()
适用于参数类型:()值:[]
在文档中搜索类org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
:
,并且在此类中,没有方法getExecutor()
。
但是有一个getRawBuild()
方法返回https://javadoc.jenkins.io/hudson/model/Run.html
所以,这可能对您有用:
currentBuild.getRawBuild().getExecutor().getElapsedTime()