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.PublisherListNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringCommand to execute.protected List<EnvVarsFilterLocalRule>List of configured environment filter rulesFields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS -
Constructor Summary
Constructors -
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 Stringprotected abstract Stringprotected abstract Stringprotected booleanisErrorlevelForUnstableBuild(int exitCode) Determines whether a non-zero exit code from the process should change the build status toResult.UNSTABLEinstead of defaultResult.FAILURE.protected intReports the exit code from the process.booleanperform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) Runs the step over the given build and reports the progress to the listener.booleanperform(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) Methods inherited from class hudson.tasks.Builder
all, getDescriptor, getRequiredMonitorService, prebuildMethods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, prebuild
-
Field Details
-
command
Command to execute. The format depends on the actualCommandInterpreterimplementation. -
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:EnvVarsFilterableBuilderThe 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:
buildEnvVarsFilterRulesin 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:BuildStepRuns 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 noQueueItemAuthenticatorwas available, configured, and active.- Specified by:
performin interfaceBuildStep- Overrides:
performin 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 theBuildStepimplementations 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.UNSTABLEinstead of defaultResult.FAILURE. Changing toResult.UNSTABLEdoes 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:
IOExceptionInterruptedException- Since:
- 1.549
-
createScriptFile
Creates a script file in a temporary name in the specified directory.- Throws:
IOExceptionInterruptedException
-
buildCommandLine
-
getContents
-
getFileExtension
-