Java Code Examples for hudson.model.CauseAction#getCauses()

The following examples show how to use hudson.model.CauseAction#getCauses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildFlowAction.java    From yet-another-build-visualizer-plugin with MIT License 6 votes vote down vote up
private static Run getUpstreamBuild(@Nonnull Run build) {
  CauseAction causeAction = build.getAction(CauseAction.class);
  if (causeAction == null) {
    return null;
  }
  for (Cause cause : causeAction.getCauses()) {
    if (cause instanceof Cause.UpstreamCause) {
      Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause;
      Job upstreamJob =
          Jenkins.getInstance().getItemByFullName(upstreamCause.getUpstreamProject(), Job.class);
      // We want to ignore rebuilds, rebuilds have the same parent as
      // original build, see BuildCache#updateCache().
      if (upstreamJob == null || build.getParent() == upstreamJob) {
        continue;
      }
      return upstreamJob.getBuildByNumber(upstreamCause.getUpstreamBuild());
    }
  }
  return null;
}
 
Example 2
Source File: CauseActionConverter.java    From DotCi with MIT License 5 votes vote down vote up
@Override
public Object encode(final Object value, final MappedField optionalExtraInfo) {
    if (value == null) return null;
    final CauseAction action = (CauseAction) value;
    final List causes = new BasicDBList();

    for (final Object obj : action.getCauses()) {
        causes.add(getMapper().toDBObject(obj));
    }
    return BasicDBObjectBuilder.start("causes", causes).add("className", CauseAction.class.getName()).get();
}