hudson.model.AbstractProject.isBuildable()方法的使用及代码示例

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

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

AbstractProject.isBuildable介绍

暂无

代码示例

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

return NO_CHANGES;
if (!isBuildable()) {
  listener.getLogger().println(Messages.AbstractProject_Disabled());
  return NO_CHANGES;

代码示例来源:origin: org.hudsonci.plugins/rest-plugin-api

@GET
@Path("{projectName}/schedule")
public Response scheduleBuild(final @PathParam("projectName") String projectName) {
  log.debug("Scheduling build: {}", projectName);
  AbstractProject project = support.getProject(projectName);
  if (!project.isBuildable()) {
    throw new RuntimeException("Project not buildable: " + projectName);
  }
  project.checkPermission(BUILD);
  // TODO: Support delay (as query param)
  project.scheduleBuild(new Cause.UserCause());
  return Response.noContent().build();
}

代码示例来源:origin: org.hudsonci.plugins/parameterized-trigger

@Override
protected Future schedule(AbstractBuild<?, ?> build, AbstractProject project, List<Action> list) throws InterruptedException, IOException {
  if (block!=null) {
    while (true) {
      // if we fail to add the item to the queue, wait and retry.
      // it also means we have to force quiet period = 0, or else it'll never leave the queue
      Future f = project.scheduleBuild2(0, new UpstreamCause((Run) build), list.toArray(new Action[list.size()]));
      //when a project is disabled or the configuration is not yet saved f will always be null and we'ure caught in a loop, therefore we need to check for it
      if (f!=null || (f==null && !project.isBuildable())){
        return f;
      }
      Thread.sleep(1000);
    }
  } else {
    return super.schedule(build,project,list);
  }
}

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

@Override
protected SearchIndexBuilder makeSearchIndex() {
  SearchIndexBuilder sib = super.makeSearchIndex();
  if(isBuildable() && hasPermission(Hudson.ADMINISTER))
    sib.add("build","build");
  return sib;
}

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

@Override
protected SearchIndexBuilder makeSearchIndex() {
  SearchIndexBuilder sib = super.makeSearchIndex();
  if (isBuildable() && hasPermission(Hudson.ADMINISTER)) {
    sib.add("build", "build");
  }
  return sib;
}

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

@Override
protected SearchIndexBuilder makeSearchIndex() {
  SearchIndexBuilder sib = super.makeSearchIndex();
  if (isBuildable() && hasPermission(Hudson.ADMINISTER)) {
    sib.add("build", "build");
  }
  return sib;
}

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

@Override
protected SearchIndexBuilder makeSearchIndex() {
  SearchIndexBuilder sib = super.makeSearchIndex();
  if(isBuildable() && hasPermission(Hudson.ADMINISTER))
    sib.add("build","build");
  return sib;
}

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

/**
 * Schedules a build of this project, and returns a {@link Future} object
 * to wait for the completion of the build.
 *
 * @param actions
 *      For the convenience of the caller, this collection can contain null, and those will be silently ignored.
 * @since 1.383
 */
public Future<R> scheduleBuild2(int quietPeriod, Cause c, Collection<? extends Action> actions) {
  if (!isBuildable())
    return null;
  List<Action> queueActions = new ArrayList<Action>(actions);
  if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) {
    queueActions.add(new ParametersAction(getDefaultParametersValues()));
  }
  if (c != null) {
    queueActions.add(new CauseAction(c));
  }
  WaitingItem i = Hudson.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
  if(i!=null)
    return (Future)i.getFuture();
  return null;
}

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

/**
 * Schedules a build of this project, and returns a {@link Future} object
 * to wait for the completion of the build.
 *
 * @param actions
 *      For the convenience of the caller, this collection can contain null, and those will be silently ignored.
 * @since 1.383
 */
public Future<R> scheduleBuild2(int quietPeriod, Cause c, Collection<? extends Action> actions) {
  if (!isBuildable())
    return null;
  List<Action> queueActions = new ArrayList<Action>(actions);
  if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) {
    queueActions.add(new ParametersAction(getDefaultParametersValues()));
  }
  if (c != null) {
    queueActions.add(new CauseAction(c));
  }
  WaitingItem i = Hudson.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
  if(i!=null)
    return (Future)i.getFuture();
  return null;
}

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

/**
 * Schedules a build of this project, and returns a {@link Future} object to
 * wait for the completion of the build.
 *
 * @param actions For the convenience of the caller, this collection can
 * contain null, and those will be silently ignored.
 * @since 1.383
 */
public Future<R> scheduleBuild2(int quietPeriod, Cause c, Collection<? extends Action> actions) {
  if (!isBuildable()) {
    return null;
  }
  List<Action> queueActions = new ArrayList<Action>(actions);
  if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) {
    queueActions.add(new ParametersAction(getDefaultParametersValues()));
  }
  if (c != null) {
    queueActions.add(new CauseAction(c));
  }
  WaitingItem i = Hudson.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
  if (i != null) {
    return (Future) i.getFuture();
  }
  return null;
}

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

/**
 * Schedules a build of this project, and returns a {@link Future} object to
 * wait for the completion of the build.
 *
 * @param actions For the convenience of the caller, this collection can
 * contain null, and those will be silently ignored.
 * @since 1.383
 */
public Future<R> scheduleBuild2(int quietPeriod, Cause c, Collection<? extends Action> actions) {
  if (!isBuildable()) {
    return null;
  }
  List<Action> queueActions = new ArrayList<Action>(actions);
  if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) {
    queueActions.add(new ParametersAction(getDefaultParametersValues()));
  }
  if (c != null) {
    queueActions.add(new CauseAction(c));
  }
  WaitingItem i = Hudson.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
  if (i != null) {
    return (Future) i.getFuture();
  }
  return null;
}

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

/**
 * Method for checking,whether the rebuild functionality would be available
 * for build.
 *
 * @return boolean
 */
public boolean isRebuildAvailable() {
  return getProject() != null && getProject().hasPermission(AbstractProject.BUILD)
      && getProject().isBuildable() && !(getProject().isDisabled()) && !isMatrixRun();
}

代码示例来源:origin: org.jenkins-ci.lib/xtrigger-lib

@Override
public void run() {
  AbstractProject project = (AbstractProject) job;
  XTriggerDescriptor descriptor = getDescriptor();
  ExecutorService executorService = descriptor.getExecutor();
  XTriggerLog log = null;
  try {
    StreamTaskListener listener = new StreamTaskListener(getLogFile());
    log = new XTriggerLog(listener);
    if (Hudson.getInstance().isQuietingDown()) {
      log.info("Jenkins is quieting down.");
    } else if (!project.isBuildable()) {
      log.info("The job is not buildable. Activate it to poll again.");
    } else if (!unblockConcurrentBuild && project.isBuilding()) {
      log.info("The job is building. Waiting for next poll.");
    } else {
      Runner runner = new Runner(getName());
      executorService.execute(runner);
    }
  } catch (Throwable t) {
    LOGGER.log(Level.SEVERE, "Severe error during the trigger execution " + t.getMessage());
    t.printStackTrace();
  } finally {
    if (log != null) {
      log.closeQuietly();
    }
  }
}

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

/**
 * Schedules a new build command.
 */
public void doBuild( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  BuildAuthorizationToken.checkPermission(this, authToken, req, rsp);
  // if a build is parameterized, let that take over
  ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class);
  if (pp != null) {
    pp._doBuild(req,rsp);
    return;
  }
  if (!isBuildable())
    throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR,new IOException(getFullName()+" is not buildable"));
  Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
  rsp.forwardToPreviousPage(req);
}

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

/**
 * Schedules a new build command.
 */
public void doBuild( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  BuildAuthorizationToken.checkPermission(this, authToken, req, rsp);
  // if a build is parameterized, let that take over
  ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class);
  if (pp != null) {
    pp._doBuild(req,rsp);
    return;
  }
  if (!isBuildable())
    throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR,new IOException(getFullName()+" is not buildable"));
  Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
  rsp.forwardToPreviousPage(req);
}

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

/**
 * Schedules a new build command.
 */
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  BuildAuthorizationToken.checkPermission(this, authToken, req, rsp);
  // if a build is parameterized, let that take over
  ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class);
  if (pp != null) {
    pp._doBuild(req, rsp);
    return;
  }
  if (!isBuildable()) {
    throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR, new IOException(getFullName() + " is not buildable"));
  }
  Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
  rsp.forwardToPreviousPage(req);
}

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

AbstractProject project = PowerMockito.mock(AbstractProject.class);
when(project.getFullName()).thenReturn("MockedProject");
when(project.isBuildable()).thenReturn(true);
verify(project).isBuildable();
verify(eventListener, never()).schedule(
    any(GerritTrigger.class),

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

/**
 * Schedules a new build command.
 */
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  BuildAuthorizationToken.checkPermission(this, authToken, req, rsp);
  
  if (!isBuildable()) {
    throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR, new IOException(getFullName() + " is not buildable"));
  }
  // if a build is parameterized, let that take over
  ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class);
  if (pp != null) {
    synchronized(buildSchedulelock) {
      pp.setOwner(this);
      pp._doBuild(req, rsp);
    }
    return;
  }
  Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
  rsp.forwardToPreviousPage(req);
}

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

/**
 * Creates a mocked {@link AbstractProject} that returns the provided name and parameters
 * @param name the name
 * @param parameterDefinitionList the list of parameters or
 *              {@code null} to not mock the {@link ParametersDefinitionProperty} at all.
 * @return the mocked project
 */
private AbstractProject mockProject(String name, List<ParameterDefinition> parameterDefinitionList) {
  AbstractProject project = PowerMockito.mock(AbstractProject.class);
  when(project.getFullDisplayName()).thenReturn(name);
  when(project.getFullName()).thenReturn(name);
  when(project.isBuildable()).thenReturn(true);
  if (parameterDefinitionList != null) {
    ParametersDefinitionProperty parameters = mock(ParametersDefinitionProperty.class);
    when(parameters.getParameterDefinitions()).thenReturn(parameterDefinitionList);
    when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(parameters);
  }
  return project;
}

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

/**
 * Tests {@link EventListener#gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent)}.
 * With a ManualPatchsetCreated event and silentMode on.
 */
@Test
public void testGerritEventManualEventSilentMode() {
  AbstractProject project = PowerMockito.mock(AbstractProject.class);
  when(project.getFullName()).thenReturn("MockProject");
  when(project.isBuildable()).thenReturn(true);
  Queue queue = mockConfig(project);
  PowerMockito.mockStatic(ToGerritRunListener.class);
  ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class);
  PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);
  GerritProject gP = mock(GerritProject.class);
  doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class));
  when(gP.getFilePaths()).thenReturn(null);
  GerritTrigger trigger = Setup.createDefaultTrigger(project);
  Setup.setTrigger(trigger, project);
  trigger.setGerritProjects(Collections.nCopies(1, gP));
  //Whitebox.setInternalState(trigger, "job", project);
  ManualPatchsetCreated event = Setup.createManualPatchsetCreated();
  EventListener eventListener = trigger.createListener();
  eventListener = spy(eventListener);
  eventListener.gerritEvent(event);
  verify(listener, never()).onTriggered(same(project), same(event));
  verify(eventListener).schedule(same(trigger), argThat(new IsAManualCause(true)), same(event));
  verify(queue).schedule2(same(project), eq(0), hasCauseActionContainingCause(null));
}

相关文章

微信公众号

最新文章

更多

AbstractProject类方法