private void createLabel()

in clearcase-server/src/jetbrains/buildServer/buildTriggers/vcs/clearcase/ClearCaseSupport.java [815:852]


  private void createLabel(final String label, final VcsRoot root) throws VcsException {
    try {
      ClearCaseInteractiveProcessPool.doWithProcess(getViewPath(root).getWholePath(), new ClearCaseInteractiveProcessPool.ProcessRunnable() {
        public void run(@NotNull final ClearCaseInteractiveProcess process) throws VcsException {
          final boolean useGlobalLabel = "true".equals(root.getProperty(Constants.USE_GLOBAL_LABEL));
          try {
            final List<String> parameters = new ArrayList<String>();
            parameters.add("mklbtype");
            if (useGlobalLabel) {
              parameters.add("-global");
            }
            if (ClearCaseConnection.isLabelExists(process, label)) {
              parameters.add("-replace");
            }
            parameters.add("-c");
            parameters.add("Label created by TeamCity");
            if (useGlobalLabel) {
              final String globalLabelsVob = root.getProperty(Constants.GLOBAL_LABELS_VOB);
              parameters.add(label + "@" + globalLabelsVob);
            } else {
              parameters.add(label);
            }
            try {
              process.executeAndReturnProcessInput(makeArray(parameters)).close();
            } catch (final IOException ignore) {}
          }
          catch (final Exception e) {
            if (!e.getLocalizedMessage().contains("already exists")) {
              throw new VcsException(e);//e;
            }
          }
        }
      });
    }
    catch (final IOException e) {
      throw new VcsException(e);
    }
  }