@Override
  public String getExecutable(AbstractBuildContext buildContext) throws TaskException {
    ReadOnlyCapabilitySet capabilitySet = capabilityContext.getCapabilitySet();
    if (capabilitySet == null) {
      return null;
    }
    Capability capability = capabilitySet.getCapability(IVY_KEY + buildContext.getExecutable());
    if (capability == null) {
      throw new TaskException(
          "Ivy capability: "
              + buildContext.getExecutable()
              + " is not defined, please check job configuration");
    }
    final String path =
        new StringBuilder(capability.getValue())
            .append(File.separator)
            .append("bin")
            .append(File.separator)
            .append(EXECUTABLE_NAME)
            .toString();

    if (!new File(path).exists()) {
      throw new TaskException(
          "Executable '" + EXECUTABLE_NAME + "'  does not exist at path '" + path + "'");
    }

    return path;
  }
  @Override
  public void afterSuccessfulReleaseVersionBuild() throws IOException, InterruptedException {
    AbstractBuildContext context = AbstractBuildContext.createContextFromMap(configuration);
    AbstractBuildContext.ReleaseManagementContext releaseManagementContext =
        context.releaseManagementContext;
    String labelChangeListId = configuration.get("repository.revision.number");
    if (modifiedFilesForReleaseVersion) {
      log("Submitting release version changes");
      labelChangeListId = currentChangeListId + "";
      perforce.commitWorkingCopy(currentChangeListId, releaseManagementContext.getTagComment());
    } else {
      safeRevertWorkingCopy();
      currentChangeListId = perforce.getDefaultChangeListId();
    }

    if (releaseManagementContext.isCreateVcsTag()) {
      log(
          "Creating label: '"
              + releaseManagementContext.getTagUrl()
              + "' with change list id: "
              + labelChangeListId);
      perforce.createTag(
          releaseManagementContext.getTagUrl(),
          releaseManagementContext.getTagComment(),
          labelChangeListId);
      tagCreated = true;
    }
  }
 @Override
 public void buildCompleted(BuildContext buildContext) throws IOException, InterruptedException {
   AbstractBuildContext context = AbstractBuildContext.createContextFromMap(configuration);
   CurrentBuildResult result = buildContext.getBuildResult();
   if (!BuildState.SUCCESS.equals(result.getBuildState())) {
     safeRevertWorkingCopy();
     if (tagCreated) {
       safeDeleteLabel(context.releaseManagementContext.getTagUrl());
     }
   } else {
     log("Closing connection to perforce server");
     perforce.closeConnection();
   }
 }
 @Override
 public void afterDevelopmentVersionChange(boolean modified)
     throws IOException, InterruptedException {
   super.afterDevelopmentVersionChange(modified);
   AbstractBuildContext context = AbstractBuildContext.createContextFromMap(configuration);
   AbstractBuildContext.ReleaseManagementContext releaseManagementContext =
       context.releaseManagementContext;
   if (modified) {
     log("Submitting next development version changes");
     perforce.commitWorkingCopy(
         currentChangeListId, releaseManagementContext.getNextDevelopmentComment());
   } else {
     safeRevertWorkingCopy();
     currentChangeListId = perforce.getDefaultChangeListId();
   }
 }