hudson.model.Build类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(160)

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

Build介绍

[英]A build of a Project. Steps of a build

Roughly speaking, a Build goes through the following stages: SCM checkout Hudson decides which directory to use for a build, then the source code is checked out Pre-build steps Everyone gets their BuildStep#prebuild(AbstractBuild,BuildListener) invoked to indicate that the build is starting Build wrapper set up BuildWrapper#setUp(AbstractBuild,Launcher,BuildListener) is invoked. This is normally to prepare an environment for the build. Builder runs Builder#perform(AbstractBuild,Launcher,BuildListener) is invoked. This is where things that are useful to users happen, like calling Ant, Make, etc. Recorder runs Recorder#perform(AbstractBuild,Launcher,BuildListener) is invoked. This is normally to record the output from the build, such as test results. Notifier runs Notifier#perform(AbstractBuild,Launcher,BuildListener) is invoked. This is normally to send out notifications, based on the results determined so far.

And beyond that, the build is considered complete, and from then on Build object is there to keep the record of what happened in this build.
[中]一个项目的构建。构建步骤
粗略地说,构建要经历以下几个阶段:SCM签出Hudson决定构建要使用哪个目录,然后签出源代码预构建步骤每个人都会调用他们的构建步骤#预构建(AbstractBuild,BuildListener)以指示构建正在启动构建包装器设置构建包装器#调用设置(AbstractBuild,Launcher,BuildListener)。这通常是为构建准备一个环境。Builder运行Builder#调用perform(AbstractBuild、Launcher、BuildListener)。这就是对用户有用的事情发生的地方,比如调用Ant、Make等。记录器运行记录器执行(AbstractBuild、Launcher、BuildListener)被调用。这通常用于记录生成的输出,例如测试结果。通知程序运行通知程序#调用执行(AbstractBuild、Launcher、BuildListener)。这通常是根据目前确定的结果发出通知。
除此之外,构建被认为是完整的,从那时起,构建对象就在那里,用来记录在这个构建中发生的事情。

代码示例

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

@Override
public void run() {
  execute(createRunner());
}

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

@Override
public void run() {
  run(createRunner());
}

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

@Override
public String getUpUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  if(req!=null) {
    List<Ancestor> ancs = req.getAncestors();
    for( int i=1; i<ancs.size(); i++) {
      if(ancs.get(i).getObject()==this) {
        Object parentObj = ancs.get(i-1).getObject();
        if(parentObj instanceof MatrixBuild || parentObj instanceof MatrixConfiguration) {
          return ancs.get(i-1).getUrl()+'/';
        }
      }
    }
  }
  return super.getDisplayName();
}

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

/**
 * If the parent {@link MatrixBuild} is kept, keep this record too.
 */
@Override
public String getWhyKeepLog() {
  MatrixBuild pb = getParentBuild();
  if(pb!=null && pb.getWhyKeepLog()!=null)
    return Messages.MatrixRun_KeptBecauseOfParent(pb);
  return super.getWhyKeepLog();
}

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

@Override
public MatrixConfiguration getParent() {// don't know why, but javac wants this
  return super.getParent();
}

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

/**
 * Returns the last Result that was successful.
 *
 * WARNING: this method is invoked dynamically from CloverProjectAction/floatingBox.jelly
 *
 * @return the last successful build result
 */
public CloverBuildAction getLastSuccessfulResult() {
  for (Build<?, ?> b = project.getLastBuild(); b != null; b = b.getPreviousBuild()) {
    if (b.getResult() == Result.FAILURE) {
      continue;
    }
    CloverBuildAction r = b.getAction(CloverBuildAction.class);
    if (r != null) {
      return r;
    }
  }
  return null;
}

代码示例来源:origin: nemccarthy/stash-pullrequest-builder-plugin

private void abortRunningJobsThatMatch(@Nonnull StashCause stashCause) {
  logger.fine("Looking for running jobs that match PR ID: " + stashCause.getPullRequestId());
  for (Object o : job.getBuilds()) {
    if (o instanceof Build) {
      Build build = (Build) o;
      if (build.isBuilding() && hasCauseFromTheSamePullRequest(build.getCauses(), stashCause)) {
        logger.info("Aborting build: " + build + " since PR is outdated");
        build.getExecutor().interrupt(Result.ABORTED);
      }
    }
  }
}

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

public String getNearestRunUrl() {
  final
  Build r = getRun();
  if (r == null) {
    return null;
  }
  if (this.dynamicBuild.getNumber() == r.getNumber()) {
    return getShortUrl() + "/console";
  }
  return Stapler.getCurrentRequest().getContextPath() + '/' + r.getUrl();
}

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

/**
 * Tests with no extensions.
 *
 * @throws IOException
 *             IOException
 * @throws InterruptedException
 *             InterruptedException
 * @throws ExecutionException
 *             ExecutionException
 */
public void testNoRebuildValidatorExtension() throws IOException,
    InterruptedException, ExecutionException {
  Project projectA = createFreeStyleProject("testFreeStyleA");
  Build buildA = (Build) projectA.scheduleBuild2(
      0,
      new Cause.UserIdCause(),
      new ParametersAction(new StringParameterValue("party",
          "megaparty"))).get();
  assertNotNull(buildA.getAction(RebuildAction.class));
}

代码示例来源:origin: i-m-c/jenkins-inheritance-plugin

/**
 * {@inheritDoc}
 */
public File getRootDir() {
  return super.getRootDir();
}

代码示例来源:origin: i-m-c/jenkins-inheritance-plugin

public void onRun() {
  super.execute(new InheritanceBuildExecution());
}

代码示例来源:origin: etsy/jenkins-master-project

@Override
public boolean isBuilding() {
 if (super.isBuilding()) {
  // If this build's executor is running, defer to that.
  return true;
 }
 return this.masterResult.isBuilding();
}

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

public DirectoryBrowserSupport doDynamic(StaplerRequest req, StaplerResponse rsp)
    throws IOException, ServletException,
    InterruptedException {
  if (publisher.isPublishHtmlReport()) {
    FilePath r = getWorkspaceReportDir();
    if (exists(r, "index.html")) {
      return new DirectoryBrowserSupport(
          this, r, "Clover Html Report", "/cloverphp/clover.gif", false);
    }
  }
  File reportDir = getLastBuildReportDir();
  if (reportDir == null || getDisplayName() == null) {
    throw new Failure(Messages.CloverProjectAction_InvalidConfiguration());
  }
  if (new File(reportDir, "clover.xml").exists()) {
    if (project.getLastBuild() != null) {
      int buildNumber = project.getLastBuild().getNumber();
      rsp.sendRedirect2("../" + buildNumber + "/cloverphp-report");
    }
  }
  throw new Failure(Messages.CloverProjectAction_HTML_NoCloverReportFound());
}

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

@Override
public void run() {
  run(createRunner());
}

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

@Override
public String getUpUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    List<Ancestor> ancs = req.getAncestors();
    for (int i = 1; i < ancs.size(); i++) {
      if (ancs.get(i).getObject() == this) {
        Object parentObj = ancs.get(i - 1).getObject();
        if (parentObj instanceof MatrixBuild || parentObj instanceof MatrixConfiguration) {
          return ancs.get(i - 1).getUrl() + '/';
        }
      }
    }
  }
  return super.getDisplayName();
}

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

/**
 * If the parent {@link MatrixBuild} is kept, keep this record too.
 */
@Override
public String getWhyKeepLog() {
  MatrixBuild pb = getParentBuild();
  if(pb!=null && pb.getWhyKeepLog()!=null)
    return Messages.MatrixRun_KeptBecauseOfParent(pb);
  return super.getWhyKeepLog();
}

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

@Override
public MatrixConfiguration getParent() {// don't know why, but javac wants this
  return super.getParent();
}

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

@Override
public Object getDynamic(final String token, final StaplerRequest req, final StaplerResponse rsp) {
  try {
    final Build item = getRun(Combination.fromString(token));
    if (item != null) {
      if (item.getNumber() == this.getNumber()) {
        return item;
      } else {
        // redirect the user to the correct URL
        String url = Functions.joinPath(item.getUrl(), req.getRestOfPath());
        final String qs = req.getQueryString();
        if (qs != null) {
          url += '?' + qs;
        }
        throw HttpResponses.redirectViaContextPath(url);
      }
    }
  } catch (final IllegalArgumentException e) {
    // failed to parse the token as Combination. Must be something else
  }
  return super.getDynamic(token, req, rsp);
}

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

/**
 * Tests with an extension returning isApplicable false.
 *
 * @throws IOException
 *             IOException
 * @throws InterruptedException
 *             InterruptedException
 * @throws ExecutionException
 *             ExecutionException
 */
public void testRebuildValidatorExtensionIsApplicableFalse()
    throws IOException, InterruptedException, ExecutionException {
  hudson.getExtensionList(RebuildValidator.class).add(0,
      new ValidatorNeverApplicable());
  Project projectA = createFreeStyleProject("testFreeStyleC");
  Build buildA = (Build) projectA.scheduleBuild2(
      0,
      new Cause.UserIdCause(),
      new ParametersAction(new StringParameterValue("party",
          "megaparty"))).get();
  assertNotNull(buildA.getAction(RebuildAction.class));
}

代码示例来源:origin: hudson.plugins/project-inheritance

/**
 * {@inheritDoc}
 */
public File getRootDir() {
  return super.getRootDir();
}

相关文章