Class CommandInterpreter
- All Implemented Interfaces:
ExtensionPoint
,Describable<Builder>
,BuildStep
,EnvVarsFilterableBuilder
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
Command to execute.protected List<EnvVarsFilterLocalRule>
List of configured environment filter rulesFields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String[]
buildCommandLine
(FilePath script) The order is respected for the execution.createScriptFile
(FilePath dir) Creates a script file in a temporary name in the specified directory.final String
protected abstract String
protected abstract String
protected boolean
isErrorlevelForUnstableBuild
(int exitCode) Determines whether a non-zero exit code from the process should change the build status toResult.UNSTABLE
instead of defaultResult.FAILURE
.protected int
Reports the exit code from the process.boolean
perform
(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) Runs the step over the given build and reports the progress to the listener.boolean
perform
(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) Methods inherited from class hudson.tasks.Builder
all, getDescriptor, getRequiredMonitorService, prebuild
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, prebuild
-
Field Details
-
command
Command to execute. The format depends on the actualCommandInterpreter
implementation. -
configuredLocalRules
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) protected List<EnvVarsFilterLocalRule> configuredLocalRulesList of configured environment filter rules
-
-
Constructor Details
-
CommandInterpreter
-
-
Method Details
-
getCommand
-
buildEnvVarsFilterRules
Description copied from interface:EnvVarsFilterableBuilder
The order is respected for the execution. Local rules will be executed before the global ones. This method is called only once per step to create theEnvVarsFilterRuleContext
. The default implementation returns an empty list; this allows build steps to support global rules.- Specified by:
buildEnvVarsFilterRules
in interfaceEnvVarsFilterableBuilder
-
getConfiguredLocalRules
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<EnvVarsFilterLocalRule> getConfiguredLocalRules() -
perform
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedExceptionDescription copied from interface:BuildStep
Runs the step over the given build and reports the progress to the listener.A plugin can contribute the action object to
Actionable.getActions()
so that a 'report' becomes a part of the persisted data ofBuild
. This is how JUnit plugin attaches the test report to a build page, for example.When this build step needs to make (direct or indirect) permission checks to
ACL
(for example, to locate other projects by name, build them, or access their artifacts) then it must be run under a specificAuthentication
. In such a case, the implementation should check whetherJenkins.getAuthentication2()
isACL.SYSTEM2
, and if so, replace it for the duration of this step withJenkins.ANONYMOUS
. (Either usingACL.impersonate2(org.springframework.security.core.Authentication)
, or by making explicit calls toACL.hasPermission2(Authentication, Permission)
.) This would typically happen when noQueueItemAuthenticator
was available, configured, and active.- Specified by:
perform
in interfaceBuildStep
- Overrides:
perform
in classBuildStepCompatibilityLayer
- Returns:
- Delegates to
SimpleBuildStep.perform(Run, FilePath, Launcher, TaskListener)
if possible, always returning true or throwing an error. - Throws:
InterruptedException
- If the build is interrupted by the user (in an attempt to abort the build.) Normally theBuildStep
implementations may simply forward the exception it got from its lower-level functions.
-
isErrorlevelForUnstableBuild
protected boolean isErrorlevelForUnstableBuild(int exitCode) Determines whether a non-zero exit code from the process should change the build status toResult.UNSTABLE
instead of defaultResult.FAILURE
. Changing toResult.UNSTABLE
does not abort the build, next steps are continued.- Since:
- 2.26
-
perform
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws InterruptedException- Throws:
InterruptedException
-
join
Reports the exit code from the process. This allows subtypes to treat the exit code differently (for example by treating non-zero exit code as if it's zero, or to set the status toResult.UNSTABLE
). Any non-zero exit code will cause the build step to fail. UseisErrorlevelForUnstableBuild(int exitCode)
to redefine the default behaviour.- Throws:
IOException
InterruptedException
- Since:
- 1.549
-
createScriptFile
Creates a script file in a temporary name in the specified directory.- Throws:
IOException
InterruptedException
-
buildCommandLine
-
getContents
-
getFileExtension
-