@Override
  public boolean perform(
      AbstractBuild<?, ?> build, Launcher launcher, final BuildListener listener) {
    if (build.getResult().isWorseOrEqualTo(Result.FAILURE)) return false;

    listener.getLogger().println(Messages.TestflightRecorder_InfoUploading());

    try {
      EnvVars vars = build.getEnvironment(listener);

      String workspace = vars.expand("$WORKSPACE");

      List<TestflightUploader.UploadRequest> urList =
          new ArrayList<TestflightUploader.UploadRequest>();

      for (TestflightTeam team : createDefaultPlusAdditionalTeams()) {
        try {
          TestflightUploader.UploadRequest ur = createPartialUploadRequest(team, vars, build);
          urList.add(ur);
        } catch (MisconfiguredJobException mje) {
          listener.getLogger().println(mje.getConfigurationMessage());
          return false;
        }
      }

      for (TestflightUploader.UploadRequest ur : urList) {
        TestflightRemoteRecorder remoteRecorder =
            new TestflightRemoteRecorder(workspace, ur, listener);

        final List<Map> parsedMaps;

        try {
          Object result = launcher.getChannel().call(remoteRecorder);
          parsedMaps = (List<Map>) result;
        } catch (UploadException ue) {
          listener
              .getLogger()
              .println(Messages.TestflightRecorder_IncorrectResponseCode(ue.getStatusCode()));
          listener.getLogger().println(ue.getResponseBody());
          return false;
        }

        if (parsedMaps.size() == 0) {
          listener.getLogger().println(Messages.TestflightRecorder_NoUploadedFile(ur.filePaths));
          return false;
        }
        for (Map parsedMap : parsedMaps) {
          addTestflightLinks(build, listener, parsedMap);
        }
      }
    } catch (Throwable e) {
      listener.getLogger().println(e);
      e.printStackTrace(listener.getLogger());
      return false;
    }

    return true;
  }
예제 #2
0
 private DTOSet getCheckedAssets(HttpServletRequest req, String matchType)
     throws ServletException {
   DTOSet dtos = new DTOSet();
   try {
     RequestParser parser = new RequestParser();
     CheckBoxProp checkProp = new CheckBoxProp("subCheck");
     checkProp.setIgnoreOtherField(true);
     parser.setCheckBoxProp(checkProp);
     parser.transData(req);
     String[] systemids = parser.getParameterValues("systemId");
     String[] assetIds = parser.getParameterValues("assetId");
     if (systemids != null) {
       int checkedCount = systemids.length;
       for (int i = 0; i < checkedCount; i++) {
         TfEtsItemMatchRecDTO dto = new TfEtsItemMatchRecDTO();
         dto.setSystemId(systemids[i]);
         dto.setAssetId(assetIds[i]);
         dto.setMatchType(matchType);
         // String flag = req.getParameter("unyokeFlag");
         String flag = "1";
         if (flag.equals("1")) { // 资产匹配撤销
           dto.setOldFinanceProp(DictConstant.FIN_PROP_ASSETS);
           dto.setNewFinanceProp(DictConstant.FIN_PROP_UNKNOW);
         } else if (flag.equals("0")) { // 转资匹配撤销
           dto.setOldFinanceProp(DictConstant.FIN_PROP_ASSETS);
           dto.setNewFinanceProp(DictConstant.FIN_PROP_PRJ);
         }
         dtos.addDTO(dto);
       }
     }
   } catch (UploadException ex) {
     ex.printLog();
     throw new ServletException(ex);
   } catch (StrException ex) {
     ex.printLog();
     throw new ServletException(ex);
   } catch (DTOException ex) {
     ex.printLog();
     throw new ServletException(ex);
   }
   return dtos;
 }