hudson.model.Run#setResult ( )源码实例Demo

下面列出了hudson.model.Run#setResult ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public void perform(LambdaUploadBuildStepVariables lambdaUploadBuildStepVariables,  Run<?, ?>  run, FilePath workspace, Launcher launcher, TaskListener listener) {

        try {
            LambdaUploadBuildStepVariables executionVariables = lambdaUploadBuildStepVariables.getClone();
            executionVariables.expandVariables(run.getEnvironment(listener));
            DeployConfig deployConfig = executionVariables.getUploadConfig();
            LambdaClientConfig lambdaClientConfig = executionVariables.getLambdaClientConfig();

            DeployCallable deployCallable = new DeployCallable(listener, workspace, deployConfig, lambdaClientConfig);
            Boolean lambdaSuccess = launcher.getChannel().call(deployCallable);

            if (!lambdaSuccess) {
                run.setResult(Result.FAILURE);
            }
            run.addAction(new LambdaUploadAction(executionVariables.getFunctionName(), lambdaSuccess));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
public void perform(LambdaPublishBuildStepVariables lambdaPublishBuildStepVariables, Run<?, ?> run, Launcher launcher, TaskListener listener) {
    try {
        LambdaPublishBuildStepVariables executionVariables = lambdaPublishBuildStepVariables.getClone();
        executionVariables.expandVariables(run.getEnvironment(listener));
        PublishConfig publishConfig = executionVariables.getPublishConfig();
        LambdaClientConfig clientConfig = executionVariables.getLambdaClientConfig();

        PublishCallable publishCallable = new PublishCallable(listener, publishConfig, clientConfig);

        LambdaPublishServiceResponse lambdaSuccess = launcher.getChannel().call(publishCallable);

        if(!lambdaSuccess.getSuccess()){
            run.setResult(Result.FAILURE);
        }

        run.addAction(new LambdaPublishAction(lambdaSuccess.getFunctionVersion(), lambdaSuccess.getFunctionAlias(), lambdaSuccess.getSuccess()));
    } catch(Exception exc) {
        throw new RuntimeException(exc);
    }
}
 
public void perform(LambdaInvokeBuildStepVariables lambdaInvokeBuildStepVariables,Run<?, ?> run, Launcher launcher, TaskListener listener) {
    try {
        LambdaInvokeBuildStepVariables executionVariables = lambdaInvokeBuildStepVariables.getClone();
        executionVariables.expandVariables(run.getEnvironment(listener));
        LambdaClientConfig clientConfig = executionVariables.getLambdaClientConfig();
        InvokeConfig invokeConfig = executionVariables.getInvokeConfig();

        InvokeCallable invokeCallable = new InvokeCallable(listener, invokeConfig, clientConfig);

        LambdaInvocationResult invocationResult = launcher.getChannel().call(invokeCallable);
        if(!invocationResult.isSuccess()){
            run.setResult(Result.FAILURE);
        }
        for (Map.Entry<String,String> entry : invocationResult.getInjectables().entrySet()) {
            run.addAction(new LambdaOutputInjectionAction(entry.getKey(), entry.getValue()));
        }
        run.getEnvironment(listener);
        run.addAction(new LambdaInvokeAction(executionVariables.getFunctionName(), invocationResult.isSuccess()));
    } catch (Exception exc) {
        throw new RuntimeException(exc);
    }
}
 
public void perform(LambdaEventSourceBuildStepVariables lambdaEventSourceBuildStepVariables, Run<?, ?> run, Launcher launcher, TaskListener listener) {
    try {
        LambdaEventSourceBuildStepVariables executionVariables = lambdaEventSourceBuildStepVariables.getClone();
        executionVariables.expandVariables(run.getEnvironment(listener));
        EventSourceConfig eventSourceConfig = executionVariables.getEventSourceConfig();
        LambdaClientConfig clientConfig = executionVariables.getLambdaClientConfig();

        EventSourceCallable eventSourceCallable = new EventSourceCallable(listener, eventSourceConfig, clientConfig);

        Boolean lambdaSuccess = launcher.getChannel().call(eventSourceCallable);

        if(!lambdaSuccess){
            run.setResult(Result.FAILURE);
        }

        run.addAction(new LambdaEventSourceAction(executionVariables.getFunctionName(), lambdaSuccess));
    } catch(Exception exc) {
        throw new RuntimeException(exc);
    }
}
 
源代码5 项目: appcenter-plugin   文件: AppCenterRecorder.java
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener taskListener) throws InterruptedException, IOException {
    final Result buildResult = run.getResult();
    if (buildResult != null && buildResult.isWorseOrEqualTo(FAILURE)) {
        taskListener.getLogger().println(Messages.AppCenterRecorder_DescriptorImpl_errors_upstreamBuildFailure());
        return;
    }

    if (uploadToAppCenter(run, filePath, taskListener)) {
        run.setResult(SUCCESS);
    } else {
        run.setResult(FAILURE);
    }
}
 
源代码6 项目: jenkins-plugin   文件: OpenShiftImageStreams.java
@Override
public void checkout(Run<?, ?> build, Launcher launcher,
        FilePath workspace, TaskListener listener, File changelogFile,
        SCMRevisionState baseline) throws IOException, InterruptedException {
    boolean chatty = Boolean.parseBoolean(verbose);

    String bldName = null;
    if (build != null)
        bldName = build.getDisplayName();
    if (chatty)
        listener.getLogger().println(
                "\n\nOpenShiftImageStreams checkout called for " + bldName);

    EnvVars env = build.getEnvironment(listener);
    lastCommitId = getCommitId(listener, env);
    if (lastCommitId == null) {
        String imageStream = getImageStreamName(env);
        String tag = getTag(env);
        listener.getLogger().println(
                String.format(MessageConstants.SCM_IMAGESTREAM_NOT_FOUND,
                        imageStream, tag));
        // We cannot yet throw an exception here because the calling code
        // will be interrupted and the SCM action
        // will not be added to the build job.
        // Just setting the build result here. An exception will be thrown
        // in the postCheckout method.
        build.setResult(Result.FAILURE);
    }
}
 
源代码7 项目: junit-plugin   文件: JUnitResultArchiver.java
@Override
public void perform(Run build, FilePath workspace, Launcher launcher,
        TaskListener listener) throws InterruptedException, IOException {
    TestResultAction action = parseAndAttach(this, null, build, workspace, launcher, listener);

    if (action != null && action.getResult().getFailCount() > 0)
        build.setResult(Result.UNSTABLE);
}
 
源代码8 项目: hubot-steps-plugin   文件: BuildListener.java
/**
 * Sends a message to given site.
 */
@SuppressFBWarnings
private void sendMessage(Run<?, ?> run, TaskListener listener, Type type, final HubotSite site,
    final String roomName, final Config config) {
  if (site != null) {
    try {
      HubotSite cloneSite = site.clone();
      if (Util.fixEmpty(roomName) != null) {
        cloneSite.setRoom(roomName);
        // To avoid using the room prefix for individual build events those explicitly specified the room name.
        cloneSite.setRoomPrefix(null);
      }
      HubotService service = new HubotService(cloneSite);
      final String buildUserName = Common
          .prepareBuildUserName(run.getCauses(), run.getEnvironment(listener));
      final String buildUserId = Common
          .prepareBuildUserId(run.getCauses(), run.getEnvironment(listener));

      final Map tokens = Common.expandMacros(config.getTokens(), run, null, listener);

      Message message = Message.builder().message(type.getStatus())
          .ts(System.currentTimeMillis()).envVars(run.getEnvironment(listener))
          .status(type.name()).tokens(tokens)
          .buildCause(Common.prepareBuildCause(run.getCauses()))
          .userId(buildUserId).userName(buildUserName).stepName(STEP.BUILD.name()).build();

      listener.getLogger().println(
          "Hubot: Sending " + type.name() + " message to room: " + cloneSite.getRoom()
              + " of site: "
              + cloneSite.getName());
      Common
          .logResponse(service.sendMessage(message), listener.getLogger(), site.isFailOnError());
    } catch (Exception e) {
      listener.getLogger()
          .println("Unable to send message to Hubot: " + Common.getRootCause(e).getMessage());
      if (site.isFailOnError()) {
        run.setResult(Result.FAILURE);
      }
    }
  }
}
 
public Result markBuildAfterError(Run<?, ?> run) {
    run.setResult(buildStatus);
    return buildStatus;
}