public void setVersions(Cluster cluster, CommandRepository commandRepository) {
    // set the repository version for the component this command is for -
    // always use the current desired version
    String serviceName = executionCommand.getServiceName();
    try {
      RepositoryVersionEntity repositoryVersion = null;
      if (!StringUtils.isEmpty(serviceName)) {
        Service service = cluster.getService(serviceName);
        if (null != service) {
          repositoryVersion = service.getDesiredRepositoryVersion();

          String componentName = executionCommand.getComponentName();
          if (!StringUtils.isEmpty(componentName)) {
            ServiceComponent serviceComponent = service.getServiceComponent(componentName);
            if (null != serviceComponent) {
              repositoryVersion = serviceComponent.getDesiredRepositoryVersion();
            }
          }
        }
      }

      Map<String, String> commandParams = executionCommand.getCommandParams();

      if (null != repositoryVersion) {
        // only set the version if it's not set and this is NOT an install
        // command
        // Some stack scripts use version for path purposes.  Sending unresolved version first (for
        // blueprints) and then resolved one would result in various issues: duplicate directories
        // (/hdp/apps/2.6.3.0 + /hdp/apps/2.6.3.0-235), parent directory not found, and file not
        // found, etc.  Hence requiring repositoryVersion to be resolved.
        if (!commandParams.containsKey(VERSION)
          && repositoryVersion.isResolved()
          && executionCommand.getRoleCommand() != RoleCommand.INSTALL) {
          commandParams.put(VERSION, repositoryVersion.getVersion());
        }

        if (null != commandRepository && repositoryVersion.isResolved() &&
          !repositoryVersion.getVersion().equals(commandRepository.getRepoVersion())) {

          commandRepository.setRepoVersion(repositoryVersion.getVersion());
          commandRepository.setResolved(true);
        }

        if (!commandParams.containsKey(HOOKS_FOLDER)) {
          commandParams.put(HOOKS_FOLDER,configuration.getProperty(Configuration.HOOKS_FOLDER));
        }
      }

      // set the desired versions of versionable components.  This is safe even during an upgrade because
      // we are "loading-late": components that have not yet upgraded in an EU will have the correct versions.
      executionCommand.setComponentVersions(cluster);
    } catch (ServiceNotFoundException serviceNotFoundException) {
      // it's possible that there are commands specified for a service where
      // the service doesn't exist yet
      LOG.warn(
        "The service {} is not installed in the cluster. No repository version will be sent for this command.",
        serviceName);
    } catch (AmbariException e) {
      throw new RuntimeException(e);
    }
  }
Gets the execution command by either de-serializing the backing JSON
command or returning the encapsulated instance which has already been
de-serialized.
<p/>
If the {@link ExecutionCommand} has configuration tags which need to be
refreshed, then this method will lookup the appropriate configuration tags
before building the final configurations to set ont he command. Therefore,
the {@link ExecutionCommand} is allowed to have no configuration tags as
long as it has been instructed to set updated ones at execution time.

@return
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java