如何解决该问题groovy.lang.MissingMethodException:没有方法签名:

时间:2019-04-04 07:32:50

标签: groovy jenkins-groovy

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());
    }

1 个答案:

答案 0 :(得分:0)

首先-您必须阅读错误。有一个答案:

  

没有方法签名:

     

org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getExecutor()

     

适用于参数类型:()值:[]

在文档中搜索类org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper

https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html

,并且在此类中,没有方法getExecutor()

但是有一个getRawBuild()方法返回https://javadoc.jenkins.io/hudson/model/Run.html

所以,这可能对您有用:

currentBuild.getRawBuild().getExecutor().getElapsedTime()