Package io.jenkins.plugins.har.cli
Class HarnessCliSupport
java.lang.Object
io.jenkins.plugins.har.cli.HarnessCliSupport
Shared logic for running the Harness CLI from the
harness Pipeline step and the
Freestyle build step.
Credentials are resolved per command, first match wins:
--profilein the command, orHARNESS_PROFILEin the build environment (for example a profile saved earlier withharness auth login);HARNESS_API_KEYin the build environment (for example fromwithCredentials);- the API token from Manage Jenkins → System → Harness CLI Configuration, passed as environment variables.
auth login or auth logout itself, so concurrent builds
and builds spanning several agents do not share credential state.
For installer-managed installations each workspace gets its own CLI home, so a profile saved
by harness auth login in one job is never visible to other jobs on the same agent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordExit code and raw (unmasked) standard output of oneharnessinvocation. -
Method Summary
Modifier and TypeMethodDescriptionstatic FilePathReturns the CLI home to use inworkspace, ornullwhen the installation was not set up byHarnessCliGitHubInstaller(e.g.static StringResolves the full path to the harness binary.static HarnessCliSupport.ResultRunsharness <args>inworkspace.static String[]stripCliName(String[] args) Drops a leadingharnessif the user typed the full command line.
-
Method Details
-
run
public static HarnessCliSupport.Result run(Launcher launcher, FilePath workspace, EnvVars env, String[] rawArgs, TaskListener listener) throws IOException, InterruptedException Runsharness <args>inworkspace. The command line, standard output and standard error are written to the build log with API tokens masked.- Throws:
IOExceptionInterruptedException
-
cliPath
Resolves the full path to the harness binary. Uses "HARNESS_CLI_PATH" when set (via the tool installer), or falls back to just the binary name so the OS PATH is searched. -
cliHome
public static FilePath cliHome(EnvVars env, FilePath workspace, boolean isWindows) throws IOException, InterruptedException Returns the CLI home to use inworkspace, ornullwhen the installation was not set up byHarnessCliGitHubInstaller(e.g. a manually installed binary), so the CLI keeps its default~/.harness.The workspace home only holds copies of the plugin specs registered in the installation's shared home; each spec records the absolute path of its plugin binary, so the binaries are not copied.
- Throws:
IOExceptionInterruptedException
-
stripCliName
Drops a leadingharnessif the user typed the full command line.
-