hudson.model.Run.getUrl()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中hudson.model.Run.getUrl方法的一些代码示例,展示了Run.getUrl的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Run.getUrl方法的具体详情如下:
包路径:hudson.model.Run
类名称:Run
方法名:getUrl

Run.getUrl介绍

[英]Returns the URL of this Run, relative to the context root of Hudson.
[中]返回此运行的URL,相对于Hudson的上下文根。

代码示例

代码示例来源:origin: jenkinsci/jenkins

public String getEntryUrl(Run entry) {
  return entry.getUrl();
}

代码示例来源:origin: jenkinsci/jenkins

public String getEntryUrl(FeedItem item) {
  return item.getBuild().getUrl() + "changes#detail" + item.idx;
}

代码示例来源:origin: jenkinsci/jenkins

public static String encodeTo(Run r) {
  return encodeTo('/'+r.getUrl(),r.getDisplayName());
}

代码示例来源:origin: jenkinsci/jenkins

public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
  TimelineEventList result = new TimelineEventList();
  for (Run r : builds.byTimestamp(min,max)) {
    Event e = new Event();
    e.start = new Date(r.getStartTimeInMillis());
    e.end   = new Date(r.getStartTimeInMillis()+r.getDuration());
    // due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "&lt;" are transformed back to "<", but not the "&#60";
    // to protect against XSS
    e.title = Util.escape(r.getFullDisplayName()).replace("&lt;", "&#60;");
    // what to put in the description?
    // e.description = "Longish description of event "+r.getFullDisplayName();
    // e.durationEvent = true;
    e.link = req.getContextPath()+'/'+r.getUrl();
    BallColor c = r.getIconColor();
    e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF);
    e.classname = "event-"+c.noAnime().toString()+" " + (c.isAnimated()?"animated":"");
    result.add(e);
  }
  return result;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void buildEnvironmentFor(Run r, EnvVars env, TaskListener listener) throws IOException, InterruptedException {
  Computer c = Computer.currentComputer();
  if (c!=null){
    EnvVars compEnv = c.getEnvironment().overrideAll(env);
    env.putAll(compEnv);
  }
  env.put("BUILD_DISPLAY_NAME",r.getDisplayName());
  Jenkins j = Jenkins.getInstance();
  String rootUrl = j.getRootUrl();
  if(rootUrl!=null) {
    env.put("BUILD_URL", rootUrl+r.getUrl());
  }
}

代码示例来源:origin: jenkinsci/gitlab-plugin

public void execute(StaplerResponse response) {
    if (build != null) {
      try {
        response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getUrl());
      } catch (IOException e) {
        try {
          response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getBuildStatusUrl());
        } catch (IOException e1) {
          throw HttpResponses.error(500, "Failed to redirect to build page");
        }
      }
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Exposes the name/value as an environment variable.
 */
@Override
public void buildEnvironment(Run<?,?> build, EnvVars env) {
  Run run = getRun();
  
  String value = (null == run) ? "UNKNOWN" : Jenkins.getInstance().getRootUrl() + run.getUrl();
  env.put(name, value);
  env.put(name + ".jobName", getJobName());   // undocumented, left for backward compatibility
  env.put(name + "_JOBNAME", getJobName());   // prefer this version
  env.put(name + ".number" , getNumber ());   // same as above
  env.put(name + "_NUMBER" , getNumber ());
  
  // if run is null, default to the standard '#1' display name format
  env.put(name + "_NAME",  (null == run) ? "#" + getNumber() : run.getDisplayName());  // since 1.504
  String buildResult = (null == run || null == run.getResult()) ? "UNKNOWN" : run.getResult().toString();
  env.put(name + "_RESULT",  buildResult);  // since 1.517
  env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345
}

代码示例来源:origin: jenkinsci/jenkins

@Override protected void calculate(Run<?,?> build, JSONObject element) {
  BallColor iconColor = build.getIconColor();
  element.put("iconColorOrdinal", iconColor.ordinal());
  element.put("iconColorDescription", iconColor.getDescription());
  element.put("url", build.getUrl());
  element.put("buildStatusUrl", build.getBuildStatusUrl());
  element.put("parentUrl", build.getParent().getUrl());
  element.put("parentFullDisplayName", Functions.breakableString(Functions.escape(build.getParent().getFullDisplayName())));
  element.put("displayName", build.getDisplayName());
  element.put("timestampString", build.getTimestampString());
  element.put("timestampString2", build.getTimestampString2());
  element.put("timestampString3", Util.XS_DATETIME_FORMATTER.format(new Date(build.getStartTimeInMillis())));
  Run.Summary buildStatusSummary = build.getBuildStatusSummary();
  element.put("buildStatusSummaryWorse", buildStatusSummary.isWorse);
  element.put("buildStatusSummaryMessage", buildStatusSummary.message);
}

代码示例来源:origin: jenkinsci/gitlab-plugin

private String getNote(Run<?, ?> build, TaskListener listener) {
    String message;
    if (this.replaceSuccessNote && build.getResult() == Result.SUCCESS) {
      message = replaceMacros(build, listener, this.getSuccessNoteText());
    } else if (this.replaceAbortNote && build.getResult() == Result.ABORTED) {
      message = replaceMacros(build, listener, this.getAbortNoteText());
    } else if (this.replaceUnstableNote && build.getResult() == Result.UNSTABLE) {
      message = replaceMacros(build, listener, this.getUnstableNoteText());
    } else if (this.replaceFailureNote && build.getResult() == Result.FAILURE) {
      message = replaceMacros(build, listener, this.getFailureNoteText());
    } else {
      String icon = getResultIcon(build.getResult());
      String buildUrl = Jenkins.getInstance().getRootUrl() + build.getUrl();
      message = MessageFormat.format("{0} Jenkins Build {1}\n\nResults available at: [Jenkins [{2} #{3}]]({4})",
                      icon, build.getResult().toString(), build.getParent().getDisplayName(), build.getNumber(), buildUrl);
    }
    return message;
  }
}

代码示例来源:origin: jenkinsci/ghprb-plugin

/**
 * Calculate the build URL of a build of default type. This will be overriden by specific build types.
 *
 * @return the build URL of a build of default type
 */
public String calculateBuildUrl(String publishedURL) {
  return publishedURL + "/" + build.getUrl();
}

代码示例来源:origin: io.jenkins.plugins/docker-slaves

@Override public String getUrl() {
  // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091
  Run<?,?> r = runForDisplay();
  return r != null ? r.getUrl() : "";
}

代码示例来源:origin: jenkinsci/docker-slaves-plugin

@Override public String getUrl() {
  // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091
  Run<?,?> r = runForDisplay();
  return r != null ? r.getUrl() : "";
}

代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

@Override public String getUrl() {
  // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091
  Run<?,?> r = runForDisplay();
  return r != null ? r.getUrl() : "";
}

代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync

@Override
public synchronized void onCompleted(Run run, @Nonnull TaskListener listener) {
 runsToPoll.remove(run);
 pollRun(run);
 logger.info("onCompleted " + run.getUrl());
 super.onCompleted(run, listener);
}

代码示例来源:origin: io.fabric8.jenkins.plugins/openshift-sync

@Override
public synchronized void onDeleted(Run run) {
 runsToPoll.remove(run);
 pollRun(run);
 logger.info("onDeleted " + run.getUrl());
 super.onDeleted(run);
 // TODO should we remove the OpenShift Build too?
}

代码示例来源:origin: nishio-dens/bitbucket-pullrequest-builder-plugin

void onStarted(BitbucketCause cause, Run<?, ?> build) {
  if (cause == null) {
    return;
  }
  try {
    build.setDescription(cause.getShortDescription());
    String buildUrl = getBuildUrl(build.getUrl());
    repository.setBuildStatus(cause, BuildState.INPROGRESS, buildUrl);
  } catch (IOException e) {
    logger.log(Level.SEVERE, "Can't update build description", e);
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Exposes the name/value as an environment variable.
 */
@Override
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {
  String value = Hudson.getInstance().getRootUrl() + getRun().getUrl();
  env.put(name, value);
  env.put(name.toUpperCase(Locale.ENGLISH), value); // backward compatibility pre 1.345
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Exposes the name/value as an environment variable.
 */
@Override
public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) {
  String value = Hudson.getInstance().getRootUrl() + getRun().getUrl();
  env.put(name, value);
  env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Exposes the name/value as an environment variable.
 */
@Override
public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) {
  String value = Hudson.getInstance().getRootUrl() + getRun().getUrl();
  env.put(name, value);
  env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345
}

代码示例来源:origin: groupon/DotCi

public BuildInfo(Run run) {
  this.timestamp = run.getTimestamp();
  this.url = "/" + run.getUrl();
  this.name = run.getFullDisplayName();
  this.result = run.isBuilding() ? "Building" : run.getResult().toString();
}

相关文章

微信公众号

最新文章

更多

Run类方法