Class Maven
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Builder
-
- hudson.tasks.Maven
-
- All Implemented Interfaces:
ExtensionPoint,Describable<Builder>,BuildStep
public class Maven extends Builder
Build by using Maven.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMaven.DescriptorImplstatic classMaven.MavenInstallationRepresents a Maven installation in a system.static classMaven.MavenInstallerAutomatic Maven installer from apache.org.static interfaceMaven.ProjectWithMavenOptional interface that can be implemented byAbstractProjectthat has "contextual"Maven.MavenInstallationassociated with it.-
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static Maven.DescriptorImplDESCRIPTORDeprecated.as of 1.286 UseJenkins.getDescriptorByType(Class)to obtain the current instance.StringjvmOptionsMAVEN_OPTS if not null.StringmavenNameIdentifiesMaven.MavenInstallationto be used.StringpomOptional POM file path relative to the workspace.StringpropertiesOptional properties to be passed to Maven.StringtargetsThe targets and other maven options.booleanusePrivateRepositoryIf true, the build will use its own local Maven repository via "-Dmaven.repo.local=...".-
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
-
Constructor Summary
Constructors Constructor Description Maven(String targets, String name)Maven(String targets, String name, String pom, String properties, String jvmOptions)Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository)Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository, SettingsProvider settings, GlobalSettingsProvider globalSettings)Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository, SettingsProvider settings, GlobalSettingsProvider globalSettings, boolean injectBuildVariables)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildEnvVars(EnvVars env, Maven.MavenInstallation mi)Build up the environment variables toward the Maven launch.Maven.DescriptorImplgetDescriptor()Gets the descriptor for this instance.GlobalSettingsProvidergetGlobalSettings()Maven.MavenInstallationgetMaven()Gets the Maven to invoke, or null to invoke the default one.SettingsProvidergetSettings()StringgetTargets()booleanisInjectBuildVariables()booleanperform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)Runs the step over the given build and reports the progress to the listener.protected voidsetGlobalSettings(GlobalSettingsProvider globalSettings)protected voidsetSettings(SettingsProvider settings)voidsetUsePrivateRepository(boolean usePrivateRepository)booleanusesPrivateRepository()protected voidwrapUpArguments(ArgumentListBuilder args, String normalizedTarget, AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)Allows the derived type to make additional modifications to the arguments list.-
Methods inherited from class hudson.tasks.Builder
all, getRequiredMonitorService, prebuild
-
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, prebuild
-
-
-
-
Field Detail
-
targets
public final String targets
The targets and other maven options. Can be separated by SP or NL.
-
mavenName
public final String mavenName
IdentifiesMaven.MavenInstallationto be used.
-
jvmOptions
public final String jvmOptions
MAVEN_OPTS if not null.
-
pom
public final String pom
Optional POM file path relative to the workspace. Used for the Maven '-f' option.
-
properties
public final String properties
Optional properties to be passed to Maven. FollowsPropertiessyntax.
-
usePrivateRepository
public boolean usePrivateRepository
If true, the build will use its own local Maven repository via "-Dmaven.repo.local=...".This would consume additional disk space, but provides isolation with other builds on the same machine, such as mixing SNAPSHOTS. Maven also doesn't try to coordinate the concurrent access to Maven repositories from multiple Maven process, so this helps there too. Identical to logic used in maven-plugin.
- Since:
- 1.322
-
DESCRIPTOR
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Maven.DescriptorImpl DESCRIPTOR
Deprecated.as of 1.286 UseJenkins.getDescriptorByType(Class)to obtain the current instance. For compatibility, this field retains the last createdMaven.DescriptorImpl.
-
-
Constructor Detail
-
Maven
public Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository)
-
Maven
public Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository, SettingsProvider settings, GlobalSettingsProvider globalSettings)
-
Maven
@DataBoundConstructor public Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository, SettingsProvider settings, GlobalSettingsProvider globalSettings, boolean injectBuildVariables)
-
-
Method Detail
-
getTargets
public String getTargets()
-
getSettings
public SettingsProvider getSettings()
- Since:
- 1.491
-
setSettings
protected void setSettings(SettingsProvider settings)
-
getGlobalSettings
public GlobalSettingsProvider getGlobalSettings()
- Since:
- 1.491
-
setGlobalSettings
protected void setGlobalSettings(GlobalSettingsProvider globalSettings)
-
setUsePrivateRepository
public void setUsePrivateRepository(boolean usePrivateRepository)
-
usesPrivateRepository
public boolean usesPrivateRepository()
-
isInjectBuildVariables
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isInjectBuildVariables()
-
getMaven
public Maven.MavenInstallation getMaven()
Gets the Maven to invoke, or null to invoke the default one.
-
perform
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
Description 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:
IOException- If the implementation wants to abort the processing when anIOExceptionhappens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catchIOExceptionon its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.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.
-
wrapUpArguments
protected void wrapUpArguments(ArgumentListBuilder args, String normalizedTarget, AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
Allows the derived type to make additional modifications to the arguments list.- Throws:
IOExceptionInterruptedException- Since:
- 1.344
-
buildEnvVars
protected void buildEnvVars(EnvVars env, Maven.MavenInstallation mi) throws IOException, InterruptedException
Build up the environment variables toward the Maven launch.- Throws:
IOExceptionInterruptedException
-
getDescriptor
public Maven.DescriptorImpl getDescriptor()
Description copied from interface:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, so ifa.getClass() == b.getClass()then by defaulta.getDescriptor() == b.getDescriptor()as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptorin interfaceDescribable<Builder>- Overrides:
getDescriptorin classBuilder
-
-