簡體   English   中英

如何解決問題groovy.lang.MissingMethodException:沒有方法的簽名:

[英]how to resolve the issue groovy.lang.MissingMethodException: No signature of method:

我在jenkins管道腳本中收到錯誤。 錯誤說groovy.lang.MissingMethodException:沒有方法簽名:org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getExecutor()適用於參數類型:()值:[]

我想整合jenkins和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());
    }

首先 - 你必須閱讀錯誤。 有一個答案:

沒有方法簽名:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM