hudson.model.Executor.currentExecutor()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(167)

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

Executor.currentExecutor介绍

[英]Returns the executor of the current thread or null if current thread is not an executor.
[中]返回当前线程的执行器,如果当前线程不是执行器,则返回null。

代码示例

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

synchronized void push(RunExecution r) {
  Executor e = Executor.currentExecutor();
  Stack<RunExecution> s = stack.get(e);
  if(s==null) stack.put(e,s=new Stack<RunExecution>());
  s.push(r);
}

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

synchronized void pop() {
  Executor e = Executor.currentExecutor();
  Stack<RunExecution> s = stack.get(e);
  s.pop();
  if(s.isEmpty()) stack.remove(e);
}

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

/**
 * Gets the current {@link Computer} that the build is running.
 * This method only works when called during a build, such as by
 * {@link hudson.tasks.Publisher}, {@link hudson.tasks.BuildWrapper}, etc.
 * @return the {@link Computer} associated with {@link Executor#currentExecutor}, or (consistently as of 1.591) null if not on an executor thread
 */
public static @Nullable Computer currentComputer() {
  Executor e = Executor.currentExecutor();
  return e != null ? e.getOwner() : null;
}

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

/**
 * Looks up the currently running build, if known.
 * <p>While most {@link Run} implementations do add a {@link RunExecution} to the stack for the duration of the build,
 * those which have a different implementation of {@link Run#run} (or which do additional work after {@link Run#execute} completes)
 * may not consistently or ever keep an execution on the stack.
 * In such cases this method will return null, meaning that {@link CheckPoint#block(BuildListener, String)} and {@link CheckPoint#report} will do nothing.
 * @return a running build, or null if one has not been recorded
 */
synchronized @CheckForNull RunExecution peek() {
  Executor e = Executor.currentExecutor();
  if (e != null) {
    Stack<RunExecution> s = stack.get(e);
    if (s != null && !s.isEmpty()) {
      return s.peek();
    }
  }
  return null;
}

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

@Deprecated
public void synchronizeEnd(Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
  synchronizeEnd(Executor.currentExecutor(), executable, problems, duration);
}

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

/**
 * During the build, expose the environments contributed by {@link BuildWrapper}s and others.
 * 
 * <p>
 * Since 1.444, executor thread that's doing the build can access mutable underlying list,
 * which allows the caller to add/remove environments. The recommended way of adding
 * environment is through {@link BuildWrapper}, but this might be handy for build steps
 * who wants to expose additional environment variables to the rest of the build.
 * 
 * @return can be empty list, but never null. Immutable.
 * @since 1.437
 */
public EnvironmentList getEnvironments() {
  Executor e = Executor.currentExecutor();
  if (e!=null && e.getCurrentExecutable()==this) {
    if (buildEnvironments==null)    buildEnvironments = new ArrayList<Environment>();
    return new EnvironmentList(buildEnvironments); 
  }
  
  return new EnvironmentList(buildEnvironments==null ? Collections.<Environment>emptyList() : ImmutableList.copyOf(buildEnvironments));
}

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

/**
 * Various deprecated methods in this class all need the 'current' build.  This method returns
 * the build suitable for that purpose.
 *
 * @return An AbstractBuild for deprecated methods to use.
 */
private AbstractBuild getBuildForDeprecatedMethods() {
  Executor e = Executor.currentExecutor();
  if(e!=null) {
    Executable exe = e.getCurrentExecutable();
    if (exe instanceof AbstractBuild) {
      AbstractBuild b = (AbstractBuild) exe;
      if(b.getProject()==this)
        return b;
    }
  }
  R lb = getLastBuild();
  if(lb!=null)    return lb;
  return null;
}

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

@Override
  protected void onCriteriaMet() {
    // on behalf of the member Executors,
    // the one that executes the main thing will send notifications
    // Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread.
    Executor e = Executor.currentExecutor();
    if (e.getCurrentWorkUnit().isMainWork()) {
      e.getOwner().taskAccepted(e,task);
    }
  }
};

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

/**
 * All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the start.
 */
public void synchronizeStart() throws InterruptedException {
  startLatch.synchronize();
  // the main thread will send a notification
  Executor e = Executor.currentExecutor();
  WorkUnit wu = e.getCurrentWorkUnit();
  if (wu.isMainWork()) {
    future.start.set(e.getCurrentExecutable());
  }
}

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

} catch( InterruptedException e) {
  result = Executor.currentExecutor().abortResult();
  listener.getLogger().println(Messages.Run_BuildAborted());
  Executor.currentExecutor().recordCauseOfInterruption(Run.this,listener);
  LOGGER.log(Level.INFO, this + " aborted", e);
} catch( Throwable e ) {

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

synchronized void pop() {
  Executor e = Executor.currentExecutor();
  Stack<RunExecution> s = stack.get(e);
  s.pop();
  if(s.isEmpty()) stack.remove(e);
}

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

synchronized void push(Runner r) {
  Executor e = Executor.currentExecutor();
  Stack<Runner> s = stack.get(e);
  if (s == null) {
    stack.put(e, s = new Stack<Runner>());
  }
  s.push(r);
}

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

synchronized void pop() {
  Executor e = Executor.currentExecutor();
  Stack<Runner> s = stack.get(e);
  s.pop();
  if(s.isEmpty()) stack.remove(e);
}

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

synchronized void pop() {
  Executor e = Executor.currentExecutor();
  Stack<Runner> s = stack.get(e);
  s.pop();
  if(s.isEmpty()) stack.remove(e);
}

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

/**
 * Gets the current {@link Computer} that the build is running.
 * This method only works when called during a build, such as by
 * {@link hudson.tasks.Publisher}, {@link hudson.tasks.BuildWrapper}, etc.
 * @return the {@link Computer} associated with {@link Executor#currentExecutor}, or (consistently as of 1.591) null if not on an executor thread
 */
public static @Nullable Computer currentComputer() {
  Executor e = Executor.currentExecutor();
  return e != null ? e.getOwner() : null;
}

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

/**
 * Called by the executor that executes a member {@link SubTask} that belongs to this task
 * to create its {@link WorkUnit}.
 */
public WorkUnit createWorkUnit(SubTask execUnit) {
  future.addExecutor(Executor.currentExecutor());
  WorkUnit wu = new WorkUnit(this, execUnit);
  workUnits.add(wu);
  return wu;
}

代码示例来源:origin: org.jenkins-ci.plugins/matrix-project

public ParentBuildAction() {
  final Executor currentExecutor = Executor.currentExecutor();
  this.parent = currentExecutor != null 
      ? (MatrixBuild)currentExecutor.getCurrentExecutable() : null;
  parentId = parent != null ? parent.getExternalizableId() : null;
}

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

/**
 * Gets the current {@link Computer} that the build is running.
 * This method only works when called during a build, such as by
 * {@link Publisher}, {@link BuildWrapper}, etc.
 */
public static Computer currentComputer() {
  Executor e = Executor.currentExecutor();
  // If no executor then must be on master node
  return e != null ? e.getOwner() : Hudson.getInstance().toComputer();
}

代码示例来源:origin: org.hudsonci.plugins/ivy

private Object writeReplace() {
    // when called from remote, methods need to be executed in the
    // proper Executor's context.
    return Channel.current().export(IvyBuildProxy2.class, Executor.currentExecutor().newImpersonatingProxy(IvyBuildProxy2.class, this));
  }
}

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

@Override
  protected void onCriteriaMet() {
    // on behalf of the member Executors,
    // the one that executes the main thing will send notifications
    // Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread.
    Executor e = Executor.currentExecutor();
    if (e.getCurrentWorkUnit().isMainWork()) {
      e.getOwner().taskAccepted(e,task);
    }
  }
};

相关文章