Package io.jenkins.plugins.dotnet
Class DotNetSDK
java.lang.Object
hudson.model.AbstractDescribableImpl<ToolInstallation>
hudson.tools.ToolInstallation
io.jenkins.plugins.dotnet.DotNetSDK
- All Implemented Interfaces:
ExtensionPoint
,Describable<ToolInstallation>
,EnvironmentSpecific<DotNetSDK>
,NodeSpecific<DotNetSDK>
,Serializable
public final class DotNetSDK
extends ToolInstallation
implements NodeSpecific<DotNetSDK>, EnvironmentSpecific<DotNetSDK>
An installation of a .NET SDK as a global tool.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A descriptor for .NET SDK installations.Nested classes/interfaces inherited from class hudson.tools.ToolInstallation
ToolInstallation.ToolConverter
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addSdks
(ListBoxModel model) Adds the names of all defined .NET SDK installations to a listbox model.void
buildEnvVars
(EnvVars env) Sets up environment variables for this .NET SDK installation.boolean
createGlobalJson
(FilePath dir, TaskListener listener) Create aglobal.json
in the specified location, forcing the use of this .NET SDK's exact version.ensureExecutableExists
(Launcher launcher) Ensures that thedotnet
executable exists in this .NET SDK installation.forEnvironment
(EnvVars envVars) Creates a copy of this .NET SDK installation that has the specified environment variables applied.forNode
(Node node, TaskListener listener) Creates a copy of this .NET SDK installation for use on the specified node.static String
getExecutableFileName
(Launcher launcher) Returns the file name for thedotnet
executable on the agent platform.getHomePath
(hudson.remoting.VirtualChannel channel) Determines the file path for this SDK's home directory.static boolean
Determines whether any .NET SDKs have been configured.boolean
Determines whether the telemetry opt-out is set.static void
removeGlobalJson
(FilePath dir, TaskListener listener) Removes aglobal.json
file (as previously created viacreateGlobalJson(FilePath, TaskListener)
.void
setTelemetryOptOut
(boolean telemetryOptOut) Determines whether the telemetry opt-out should be set.Methods inherited from class hudson.tools.ToolInstallation
all, getHome, getName, getProperties, readResolve, toString, translate, translate, translateFor, writeReplace
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Field Details
-
HOME_ENVIRONMENT_VARIABLE
Deprecated.UseROOT_ENVIRONMENT_VARIABLE
instead; that environment variable is also used by the SDK itself.An environment variable that will be set to the full path to the SDK (backward compatibility).- See Also:
-
ROOT_ENVIRONMENT_VARIABLE
The environment variable that will be set to the full path to the SDK (used by the SDK in some cases).- See Also:
-
-
Constructor Details
-
DotNetSDK
Creates a new .NET SDK installation.- Parameters:
name
- The name for the installation.home
- The path to the SDK.
-
DotNetSDK
@DataBoundConstructor public DotNetSDK(@NonNull String name, @NonNull String home, @CheckForNull List<? extends ToolProperty<?>> properties) Creates a new .NET SDK installation.- Parameters:
name
- The name for the installation.home
- The path to the SDK.properties
- Additional properties for the SDK installation.
-
-
Method Details
-
isTelemetryOptOut
public boolean isTelemetryOptOut()Determines whether the telemetry opt-out is set.- Returns:
true
when the telemetry opt-out is set;false
otherwise.
-
setTelemetryOptOut
@DataBoundSetter public void setTelemetryOptOut(boolean telemetryOptOut) Determines whether the telemetry opt-out should be set.- Parameters:
telemetryOptOut
-true
to opt out of telemetry;false
otherwise.
-
addSdks
Adds the names of all defined .NET SDK installations to a listbox model.- Parameters:
model
- The listbox model to add the .NET SDK installations to.
-
buildEnvVars
Sets up environment variables for this .NET SDK installation.- Overrides:
buildEnvVars
in classToolInstallation
- Parameters:
env
- The environment variables to add values to.
-
createGlobalJson
Create aglobal.json
in the specified location, forcing the use of this .NET SDK's exact version.- Parameters:
dir
- The location where theglobal.json
should be created.listener
- The task listener to use for output- Returns:
true
when aglobal.json
file was created;false
otherwise.
-
ensureExecutableExists
@NonNull public String ensureExecutableExists(@NonNull Launcher launcher) throws IOException, InterruptedException Ensures that thedotnet
executable exists in this .NET SDK installation.- Parameters:
launcher
- The launcher to use for the verification.- Returns:
- The full path to the
dotnet
executable in this .NET SDK installation. - Throws:
AbortException
- When the executable could not be found.IOException
- When an I/O error occurs.InterruptedException
- When processing is interrupted.
-
forEnvironment
Creates a copy of this .NET SDK installation that has the specified environment variables applied.- Specified by:
forEnvironment
in interfaceEnvironmentSpecific<DotNetSDK>
- Parameters:
envVars
- The environment variables to apply.- Returns:
- A copy of this .NET SDK installation that has the specified environment variables applied.
-
forNode
@NonNull public DotNetSDK forNode(@NonNull Node node, @NonNull TaskListener listener) throws IOException, InterruptedException Creates a copy of this .NET SDK installation for use on the specified node.- Specified by:
forNode
in interfaceNodeSpecific<DotNetSDK>
- Parameters:
node
- The node to use the .NET SDK installation on.- Returns:
- A copy of this .NET SDK installation for use on
node
. - Throws:
IOException
InterruptedException
-
getExecutableFileName
Returns the file name for thedotnet
executable on the agent platform.- Parameters:
launcher
- The launcher to use to determine the agent platform.- Returns:
dotnet.exe
whenlauncher
represents a Windows agent,dotnet
otherwise.
-
getHomePath
Determines the file path for this SDK's home directory.- Parameters:
channel
- The remote context to use for the file path.- Returns:
- A file path representing this SDK's home directory, or
null
if no home directory was set.
-
hasConfiguration
public static boolean hasConfiguration()Determines whether any .NET SDKs have been configured.- Returns:
true
when at least one .NET SDK has been configured; otherwise,false
.
-
removeGlobalJson
Removes aglobal.json
file (as previously created viacreateGlobalJson(FilePath, TaskListener)
.- Parameters:
dir
- The location containing theglobal.json
file to remove.listener
- The task listener to use for output.
-
ROOT_ENVIRONMENT_VARIABLE
instead; that environment variable is also used by the SDK itself.