def exec_cli(command, args = [])
      base_dir = File.dirname(__FILE__)
      server_url = "http://#{@server_ip}:#{@server_port}/#{@jenkins_path}"
      cmd = "java -jar #{base_dir}/../../java_deps/jenkins-cli.jar -s #{server_url}"
      cmd << " -i #{@identity_file}" if @identity_file && !@identity_file.empty?
      cmd << " #{command}"
      cmd << " --username #{@username} --password #{@password}" if @identity_file.nil? || @identity_file.empty?
      cmd << ' '
      cmd << args.join(' ')
      java_cmd = Mixlib::ShellOut.new(cmd)

      # Run the command
      java_cmd.run_command
      if java_cmd.stderr.empty?
        java_cmd.stdout.chomp
      else
        # The stderr has a stack trace of the Java program. We'll already have
        # a stack trace for Ruby. So just display a descriptive message for the
        # error thrown by the CLI.
        raise Exceptions::CLIException.new(
          @logger,
          java_cmd.stderr.split("\n").first
        )
      end
    end
def exec_cli(command, args = [])
      base_dir = File.dirname(__FILE__)
      server_url = "http://#{@server_ip}:#{@server_port}/#{@jenkins_path}"
      cmd = "java -jar #{base_dir}/../../java_deps/jenkins-cli.jar -s #{server_url}"
      cmd << " -i #{@identity_file}" if @identity_file && !@identity_file.empty?
      cmd << " #{command}"
      cmd << " --username #{@username} --password #{@password}" if @identity_file.nil? || @identity_file.empty?
      cmd << ' '
      cmd << args.join(' ')
      java_cmd = Mixlib::ShellOut.new(cmd)

      # Run the command
      java_cmd.run_command
      if java_cmd.stderr.empty?
        java_cmd.stdout.chomp
      else
        # The stderr has a stack trace of the Java program. We'll already have
        # a stack trace for Ruby. So just display a descriptive message for the
        # error thrown by the CLI.
        raise Exceptions::CLIException.new(
          @logger,
          java_cmd.stderr.split("\n").first
        )
      end
    end
Execute the Jenkins CLI

 @param command [String] command name
 @param args [Array] the arguments for the command

 @return [String] command output from the CLI

 @raise [Exceptions::CLIException] if there are issues in running the
   commands using CLI