Class Command

All Implemented Interfaces:
ExtensionPoint, Describable<Builder>, BuildStep, SimpleBuildStep
Direct Known Subclasses:
ListPackage, MSBuildCommand, NuGetCommand, Restore, ToolCommand

public class Command extends Builder implements SimpleBuildStep
A build step executing a .NET CLI command.
  • Field Details

    • sdk

      @CheckForNull protected String sdk
      The name of the SDK to use.
    • showSdkInfo

      protected boolean showSdkInfo
      Flag indicating whether SDK information should be shown.
    • shutDownBuildServers

      protected boolean shutDownBuildServers
      Flag indicating whether any build servers started by the main command should be shut down.
    • unstableIfErrors

      protected boolean unstableIfErrors
      Flag indicating whether the presence of errors makes the build unstable (instead of failed).
    • unstableIfWarnings

      protected boolean unstableIfWarnings
      Flag indicating whether the presence of warnings makes the build unstable (instead of successful).
    • workDirectory

      @CheckForNull protected String workDirectory
      The working directory to use for the command. This directory is not created by the command execution.
  • Constructor Details

    • Command

      public Command()
  • Method Details

    • getDescriptor

      public CommandDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<Builder>
      Overrides:
      getDescriptor in class Builder
    • addCommandLineArguments

      protected void addCommandLineArguments(@NonNull DotNetArguments args) throws AbortException
      Adds command line arguments for this invocation of the dotnet CLI.
      Parameters:
      args - The current set of arguments.
      Throws:
      AbortException - When something goes wrong.
    • getSdkDescriptor

      @NonNull public static DotNetSDK.DescriptorImpl getSdkDescriptor() throws AbortException
      Gets the descriptor for a .NET SDK.
      Returns:
      The descriptor for a .NET SDK.
      Throws:
      AbortException - When the descriptor could not be found.
    • perform

      public void perform(@NonNull Run<?,?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher, @NonNull TaskListener listener) throws InterruptedException, IOException
      Runs this .NET command.
      Specified by:
      perform in interface SimpleBuildStep
      Parameters:
      run - The run context for the command.
      workspace - The base working directory for the command.
      env - The environment variables that apply for the command.
      launcher - The launcher to use to execute the command.
      listener - The listener to report command output to.
      Throws:
      InterruptedException - When execution is interrupted.
      IOException - When an I/O error occurs.
    • getCharset

      @CheckForNull public String getCharset()
      Gets the specific charset to use for the command's output.
      Returns:
      The specific charset to use for the command's output, or null to indicate that the build's default charset should be used.
    • setCharset

      @DataBoundSetter public void setCharset(@CheckForNull String charset)
      Sets the specific charset to use for the command's output.
      Parameters:
      charset - The specific charset to use for the command's output, or null to indicate that the build's default charset should be used.
    • isContinueOnError

      public boolean isContinueOnError()
      Determines whether the build should continue when there is an error.
      Returns:
      false if the build should be aborted when there is an error; true to set build status to failed or unstable, based on configuration, but allow the next build step to execute.
    • setContinueOnError

      @DataBoundSetter public void setContinueOnError(boolean continueOnError)
      Determines whether the build should continue when there is an error.
      Parameters:
      continueOnError - false if the build should be aborted when there is an error; true if the build status should be set to failed or unstable, based on configuration, allowing the next build step to execute.
    • getSdk

      @CheckForNull public String getSdk()
      Gets the name of the SDK to use.
      Returns:
      The name of the SDK to use, or null to use the SDK made available by the parent context (or the system).
    • setSdk

      @DataBoundSetter public void setSdk(@CheckForNull String sdk)
      Sets the name of the SDK to use.
      Parameters:
      sdk - The name of the SDK to use, or null to use the SDK made available by the parent context (or the system).
    • isShowSdkInfo

      public boolean isShowSdkInfo()
      Determines whether SDK information should be shown.
      Returns:
      true if "dotnet --info" should be run before the main command; false otherwise.
    • setShowSdkInfo

      @DataBoundSetter public void setShowSdkInfo(boolean showSdkInfo)
      Determines whether SDK information should be shown.
      Parameters:
      showSdkInfo - true if "dotnet --info" should be run before the main command; false otherwise.
    • isSpecificSdkVersion

      public boolean isSpecificSdkVersion()
      Determines whether a specific SDK version should be used.
      Returns:
      true if a global.json should be created to force the use of the configured .NET SDK (as opposed to a more recent one that happens to be installed on the build agent); false otherwise.
    • setSpecificSdkVersion

      @DataBoundSetter public void setSpecificSdkVersion(boolean specificSdkVersion)
      Determines whether a specific SDK version should be used.
      Parameters:
      specificSdkVersion - true if a global.json should be created to force the use of the configured .NET SDK (as opposed to a more recent one that happens to be installed on the build agent); false otherwise.
    • getWorkDirectory

      @CheckForNull public String getWorkDirectory()
      Gets the working directory to use for the command.
      Returns:
      The working directory to use for the command.
    • setWorkDirectory

      @DataBoundSetter public void setWorkDirectory(@CheckForNull String workDirectory)
      Sets the working directory to use for the command.
      Parameters:
      workDirectory - The working directory to use for the command.