hudson.model.AbstractBuild.getBuiltOn()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(63)

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

AbstractBuild.getBuiltOn介绍

[英]Returns a Slave on which this build was done.
[中]返回在其上完成此生成的从属。

代码示例

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

public boolean apply(R r) {
    return (r instanceof AbstractBuild) && ((AbstractBuild)r).getBuiltOn()==node;
  }
});

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

public boolean perform(AbstractBuild<?,?> build, Launcher launcher, TaskListener listener) throws InterruptedException {
  FilePath ws = build.getWorkspace();
  if (ws == null) {
    Node node = build.getBuiltOn();
    if (node == null) {
      throw new NullPointerException("no such build node: " + build.getBuiltOnStr());

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

/**
 * Gets the {@link Node} where this project was last built on.
 *
 * @return
 *      null if no information is available (for example,
 *      if no build was done yet.)
 */
public Node getLastBuiltOn() {
  // where was it built on?
  AbstractBuild b = getLastBuild();
  if(b==null)
    return null;
  else
    return b.getBuiltOn();
}

代码示例来源: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("buildStatusUrl", build.getBuildStatusUrl());
  element.put("number", build.getNumber());
  element.put("displayName", build.getDisplayName());
  element.put("duration", build.getDuration());
  element.put("durationString", build.getDurationString());
  if (build instanceof AbstractBuild) {
    AbstractBuild<?,?> b = (AbstractBuild) build;
    Node n = b.getBuiltOn();
    if (n == null) {
      String ns = b.getBuiltOnStr();
      if (ns != null && !ns.isEmpty()) {
        element.put("builtOnStr", ns);
      }
    } else if (n != Jenkins.getInstance()) {
      element.put("builtOn", n.getNodeName());
      element.put("builtOnStr", n.getDisplayName());
    } else {
      element.put("builtOnStr", hudson.model.Messages.Hudson_Computer_DisplayName());
    }
  }
}

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

/**
 * Gets the directory where this build is being built.
 *
 * <p>
 * Note to implementors: to control where the workspace is created, override
 * {@link AbstractBuildExecution#decideWorkspace(Node,WorkspaceList)}.
 *
 * @return
 *      null if the workspace is on an agent that's not connected. Note that once the build is completed,
 *      the workspace may be used to build something else, so the value returned from this method may
 *      no longer show a workspace as it was used for this build.
 * @since 1.319
 */
public final @CheckForNull FilePath getWorkspace() {
  if (workspace==null) return null;
  Node n = getBuiltOn();
  if (n==null) return null;
  return n.createPath(workspace);
}

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

private FilePath getFilePath(final AbstractBuild<?, ?> build) {
  final FilePath ws = build.getWorkspace();
  if (ws == null) {
    final Node node = build.getBuiltOn();
    if (node == null) {
      throw new RuntimeException("no such build node: " + build.getBuiltOnStr());
    }
    throw new RuntimeException("no workspace from node " + node + " which is computer " + node.toComputer() + " and has channel " + node.getChannel());
  }
  return ws;
}

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

/**
 * Convenient version of {@link #translate(Node, EnvVars, TaskListener)} that just takes a build object in progress.
 * @since 1.460
 */
public ToolInstallation translate(AbstractBuild<?,?> buildInProgress, TaskListener listener) throws IOException, InterruptedException {
  assert buildInProgress.isBuilding();
  return translate(buildInProgress.getBuiltOn(),buildInProgress.getEnvironment(listener),listener);
}

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

private PollingResult pollWithWorkspace(TaskListener listener, SCM scm, R lb, @Nonnull FilePath ws, WorkspaceList l) throws InterruptedException, IOException {
  // if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace.
  // this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319.
  //
  // OTOH, if a concurrent build is chosen, the user is willing to create a multiple workspace,
  // so better throughput is achieved over time (modulo the initial cost of creating that many workspaces)
  // by having multiple workspaces
  Node node = lb.getBuiltOn();
  Launcher launcher = ws.createLauncher(listener).decorateByEnv(getEnvironment(node,listener));
  WorkspaceList.Lease lease = l.acquire(ws, !concurrentBuild);
  try {
    String nodeName = node != null ? node.getSelfLabel().getName() : "[node_unavailable]";
    listener.getLogger().println("Polling SCM changes on " + nodeName);
    LOGGER.fine("Polling SCM changes of " + getName());
    if (pollingBaseline==null) // see NOTE-NO-BASELINE above
      calcPollingBaseline(lb,launcher,listener);
    PollingResult r = scm.poll(this, launcher, ws, listener, pollingBaseline);
    pollingBaseline = r.remote;
    return r;
  } finally {
    lease.release();
  }
}

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

private WorkspaceOfflineReason workspaceOffline(R build) throws IOException, InterruptedException {
  FilePath ws = build.getWorkspace();
  Label label = getAssignedLabel();
  if (isAllSuitableNodesOffline(build)) {
    Collection<Cloud> applicableClouds = label == null ? Jenkins.getInstance().clouds : label.getClouds();
    return applicableClouds.isEmpty() ? WorkspaceOfflineReason.all_suitable_nodes_are_offline : WorkspaceOfflineReason.use_ondemand_slave;
  }
  if (ws==null || !ws.exists()) {
    return WorkspaceOfflineReason.nonexisting_workspace;
  }
  Node builtOn = build.getBuiltOn();
  if (builtOn == null) { // node built-on doesn't exist anymore
    return WorkspaceOfflineReason.builton_node_gone;
  }
  if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t.
    return WorkspaceOfflineReason.builton_node_no_executors;
  }
  return null;
}

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

return BUILD_NOW;
} else {
  WorkspaceList l = b.getBuiltOn().toComputer().getWorkspaceList();
  return pollWithWorkspace(listener, scm, b, ws, l);

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

/**
 * Wipes out the workspace.
 */
@RequirePOST
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
  checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b!=null ? b.getWorkspace() : null;
  if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    for (WorkspaceListener wl : WorkspaceListener.all()) {
      wl.afterDelete(this);
    }
    return new HttpRedirect(".");
  } else {
    // If we get here, that means the SCM blocked the workspace deletion.
    return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
  }
}

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

/**
 * Filter the list to builds on a single node only
 */
public RunList<R> node(Node node) {
  for (Iterator<R> itr = iterator(); itr.hasNext();) {
    Run r = itr.next();
    if (!(r instanceof AbstractBuild) || ((AbstractBuild)r).getBuiltOn()!=node) {
      itr.remove();
    }
  }
  return this;
}

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

@Override
public String evaluate(AbstractBuild<?, ?> abstractBuild, TaskListener taskListener, String s) throws MacroEvaluationException, IOException, InterruptedException {
  Node node = abstractBuild.getBuiltOn();
  if( node instanceof DockerTransientNode) {
    return ((DockerTransientNode) node).getContainerId();
  }
  return null;
}

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

/**
 * If the build was on a cloud, get the ID of that cloud.
 */
public static Optional<DockerCloud> getCloudForBuild(AbstractBuild build) {
  Node node = build.getBuiltOn();
  if (node instanceof DockerTransientNode) {
    return Optional.of(((DockerTransientNode) node).getCloud());
  }
  return Optional.empty();
}

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

/**
 * Filter the list to builds on a single node only
 */
public RunList<R> node(Node node) {
  for (Iterator<R> itr = iterator(); itr.hasNext();) {
    Run r = itr.next();
    if (!(r instanceof AbstractBuild) || ((AbstractBuild)r).getBuiltOn()!=node) {
      itr.remove();
    }
  }
  return this;
}

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

/**
 * Filter the list to builds on a single node only
 */
public RunList<R> node(Node node) {
  for (Iterator<R> itr = iterator(); itr.hasNext();) {
    Run r = itr.next();
    if (!(r instanceof AbstractBuild) || ((AbstractBuild)r).getBuiltOn()!=node) {
      itr.remove();
    }
  }
  return this;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Convenient version of {@link #translate(Node, EnvVars, TaskListener)} that just takes a build object in progress.
 * @since 1.460
 */
public ToolInstallation translate(AbstractBuild<?,?> buildInProgress, TaskListener listener) throws IOException, InterruptedException {
  assert buildInProgress.isBuilding();
  return translate(buildInProgress.getBuiltOn(),buildInProgress.getEnvironment(listener),listener);
}

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

public boolean cleanWorkspace() throws IOException, InterruptedException{
  checkPermission(BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b != null ? b.getWorkspace() : null;
  if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    return true;
  } else{
    // If we get here, that means the SCM blocked the workspace deletion.
    return false;
  }
}

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

public boolean cleanWorkspace() throws IOException, InterruptedException {
  checkPermission(BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b != null ? b.getWorkspace() : null;
  if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    return true;
  } else {
    // If we get here, that means the SCM blocked the workspace deletion.
    return false;
  }
}

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

public boolean cleanWorkspace() throws IOException, InterruptedException{
  checkPermission(BUILD);
  R b = getSomeBuildWithWorkspace();
  FilePath ws = b != null ? b.getWorkspace() : null;
  if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
    ws.deleteRecursive();
    return true;
  } else{
    // If we get here, that means the SCM blocked the workspace deletion.
    return false;
  }
}

相关文章

微信公众号

最新文章

更多

AbstractBuild类方法