mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-02-19 19:44:27 +02:00
Config maven in general
This commit is contained in:
parent
81708648e4
commit
4e9e31810c
@ -104,34 +104,34 @@ func mavenBuildMetadata() config.StepData {
|
||||
{
|
||||
Name: "projectSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Aliases: []config.Alias{{Name: "maven/projectSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "globalSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Aliases: []config.Alias{{Name: "maven/globalSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "m2Path",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Aliases: []config.Alias{{Name: "maven/m2Path"}},
|
||||
},
|
||||
{
|
||||
Name: "logSuccessfulMavenTransfers",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS"},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "bool",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Aliases: []config.Alias{{Name: "maven/logSuccessfulMavenTransfers"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -48,8 +48,12 @@ func runMavenStaticCodeChecks(config *mavenExecuteStaticCodeChecksOptions, telem
|
||||
goals = append(goals, pmdMavenParameters.Goals...)
|
||||
}
|
||||
finalMavenOptions := maven.ExecuteOptions{
|
||||
Goals: goals,
|
||||
Defines: defines,
|
||||
Goals: goals,
|
||||
Defines: defines,
|
||||
ProjectSettingsFile: config.ProjectSettingsFile,
|
||||
GlobalSettingsFile: config.GlobalSettingsFile,
|
||||
M2Path: config.M2Path,
|
||||
LogSuccessfulMavenTransfers: config.LogSuccessfulMavenTransfers,
|
||||
}
|
||||
_, err := maven.Execute(&finalMavenOptions, command)
|
||||
return err
|
||||
|
@ -14,13 +14,17 @@ import (
|
||||
)
|
||||
|
||||
type mavenExecuteStaticCodeChecksOptions struct {
|
||||
SpotBugs bool `json:"spotBugs,omitempty"`
|
||||
Pmd bool `json:"pmd,omitempty"`
|
||||
MavenModulesExcludes []string `json:"mavenModulesExcludes,omitempty"`
|
||||
SpotBugsExcludeFilterFile string `json:"spotBugsExcludeFilterFile,omitempty"`
|
||||
SpotBugsIncludeFilterFile string `json:"spotBugsIncludeFilterFile,omitempty"`
|
||||
PmdExcludes []string `json:"pmdExcludes,omitempty"`
|
||||
PmdRuleSets []string `json:"pmdRuleSets,omitempty"`
|
||||
SpotBugs bool `json:"spotBugs,omitempty"`
|
||||
Pmd bool `json:"pmd,omitempty"`
|
||||
MavenModulesExcludes []string `json:"mavenModulesExcludes,omitempty"`
|
||||
SpotBugsExcludeFilterFile string `json:"spotBugsExcludeFilterFile,omitempty"`
|
||||
SpotBugsIncludeFilterFile string `json:"spotBugsIncludeFilterFile,omitempty"`
|
||||
PmdExcludes []string `json:"pmdExcludes,omitempty"`
|
||||
PmdRuleSets []string `json:"pmdRuleSets,omitempty"`
|
||||
ProjectSettingsFile string `json:"projectSettingsFile,omitempty"`
|
||||
GlobalSettingsFile string `json:"globalSettingsFile,omitempty"`
|
||||
M2Path string `json:"m2Path,omitempty"`
|
||||
LogSuccessfulMavenTransfers bool `json:"logSuccessfulMavenTransfers,omitempty"`
|
||||
}
|
||||
|
||||
// MavenExecuteStaticCodeChecksCommand Execute static code checks for Maven based projects. The plugins SpotBugs and PMD are used.
|
||||
@ -70,6 +74,10 @@ func addMavenExecuteStaticCodeChecksFlags(cmd *cobra.Command, stepConfig *mavenE
|
||||
cmd.Flags().StringVar(&stepConfig.SpotBugsIncludeFilterFile, "spotBugsIncludeFilterFile", os.Getenv("PIPER_spotBugsIncludeFilterFile"), "Path to a filter file with bug definitions which should be included.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.PmdExcludes, "pmdExcludes", []string{}, "A comma-separated list of exclusions (.java source files) expressed as an Ant-style pattern relative to the sources root folder, i.e. application/src/main/java for maven projects.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.PmdRuleSets, "pmdRuleSets", []string{}, "The PMD rulesets to use. See the Stock Java Rulesets for a list of available rules. Defaults to a custom ruleset provided by this maven plugin.")
|
||||
cmd.Flags().StringVar(&stepConfig.ProjectSettingsFile, "projectSettingsFile", os.Getenv("PIPER_projectSettingsFile"), "Path to the mvn settings file that should be used as project settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.GlobalSettingsFile, "globalSettingsFile", os.Getenv("PIPER_globalSettingsFile"), "Path to the mvn settings file that should be used as global settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.M2Path, "m2Path", os.Getenv("PIPER_m2Path"), "Path to the location of the local repository that should be used.")
|
||||
cmd.Flags().BoolVar(&stepConfig.LogSuccessfulMavenTransfers, "logSuccessfulMavenTransfers", false, "Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.")
|
||||
|
||||
}
|
||||
|
||||
@ -135,6 +143,38 @@ func mavenExecuteStaticCodeChecksMetadata() config.StepData {
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "pmd/ruleSets"}},
|
||||
},
|
||||
{
|
||||
Name: "projectSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/projectSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "globalSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/globalSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "m2Path",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/m2Path"}},
|
||||
},
|
||||
{
|
||||
Name: "logSuccessfulMavenTransfers",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "bool",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/logSuccessfulMavenTransfers"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -15,14 +15,14 @@ import (
|
||||
|
||||
type mavenExecuteOptions struct {
|
||||
PomPath string `json:"pomPath,omitempty"`
|
||||
ProjectSettingsFile string `json:"projectSettingsFile,omitempty"`
|
||||
GlobalSettingsFile string `json:"globalSettingsFile,omitempty"`
|
||||
M2Path string `json:"m2Path,omitempty"`
|
||||
Goals []string `json:"goals,omitempty"`
|
||||
Defines []string `json:"defines,omitempty"`
|
||||
Flags []string `json:"flags,omitempty"`
|
||||
LogSuccessfulMavenTransfers bool `json:"logSuccessfulMavenTransfers,omitempty"`
|
||||
ReturnStdout bool `json:"returnStdout,omitempty"`
|
||||
ProjectSettingsFile string `json:"projectSettingsFile,omitempty"`
|
||||
GlobalSettingsFile string `json:"globalSettingsFile,omitempty"`
|
||||
M2Path string `json:"m2Path,omitempty"`
|
||||
LogSuccessfulMavenTransfers bool `json:"logSuccessfulMavenTransfers,omitempty"`
|
||||
}
|
||||
|
||||
// MavenExecuteCommand This step allows to run maven commands
|
||||
@ -62,14 +62,14 @@ func MavenExecuteCommand() *cobra.Command {
|
||||
|
||||
func addMavenExecuteFlags(cmd *cobra.Command, stepConfig *mavenExecuteOptions) {
|
||||
cmd.Flags().StringVar(&stepConfig.PomPath, "pomPath", os.Getenv("PIPER_pomPath"), "Path to the pom file that should be used.")
|
||||
cmd.Flags().StringVar(&stepConfig.ProjectSettingsFile, "projectSettingsFile", os.Getenv("PIPER_projectSettingsFile"), "Path to the mvn settings file that should be used as project settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.GlobalSettingsFile, "globalSettingsFile", os.Getenv("PIPER_globalSettingsFile"), "Path to the mvn settings file that should be used as global settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.M2Path, "m2Path", os.Getenv("PIPER_m2Path"), "Path to the location of the local repository that should be used.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.Goals, "goals", []string{}, "Maven goals that should be executed.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.Defines, "defines", []string{}, "Additional properties in form of -Dkey=value.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.Flags, "flags", []string{}, "Flags to provide when running mvn.")
|
||||
cmd.Flags().BoolVar(&stepConfig.LogSuccessfulMavenTransfers, "logSuccessfulMavenTransfers", false, "Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.")
|
||||
cmd.Flags().BoolVar(&stepConfig.ReturnStdout, "returnStdout", false, "Returns the output of the maven command for further processing.")
|
||||
cmd.Flags().StringVar(&stepConfig.ProjectSettingsFile, "projectSettingsFile", os.Getenv("PIPER_projectSettingsFile"), "Path to the mvn settings file that should be used as project settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.GlobalSettingsFile, "globalSettingsFile", os.Getenv("PIPER_globalSettingsFile"), "Path to the mvn settings file that should be used as global settings file.")
|
||||
cmd.Flags().StringVar(&stepConfig.M2Path, "m2Path", os.Getenv("PIPER_m2Path"), "Path to the location of the local repository that should be used.")
|
||||
cmd.Flags().BoolVar(&stepConfig.LogSuccessfulMavenTransfers, "logSuccessfulMavenTransfers", false, "Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.")
|
||||
|
||||
cmd.MarkFlagRequired("goals")
|
||||
}
|
||||
@ -88,30 +88,6 @@ func mavenExecuteMetadata() config.StepData {
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "projectSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "globalSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "m2Path",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "goals",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
@ -136,14 +112,6 @@ func mavenExecuteMetadata() config.StepData {
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "logSuccessfulMavenTransfers",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS"},
|
||||
Type: "bool",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "returnStdout",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
@ -152,6 +120,38 @@ func mavenExecuteMetadata() config.StepData {
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "projectSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/projectSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "globalSettingsFile",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/globalSettingsFile"}},
|
||||
},
|
||||
{
|
||||
Name: "m2Path",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/m2Path"}},
|
||||
},
|
||||
{
|
||||
Name: "logSuccessfulMavenTransfers",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "bool",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "maven/logSuccessfulMavenTransfers"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -28,31 +28,55 @@ spec:
|
||||
scope:
|
||||
- PARAMETERS
|
||||
default: false
|
||||
|
||||
# Global maven settings, should be added to all maven steps
|
||||
- name: projectSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as project settings file.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/projectSettingsFile
|
||||
- name: globalSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as global settings file.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/globalSettingsFile
|
||||
- name: m2Path
|
||||
type: string
|
||||
description: Path to the location of the local repository that should be used.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/m2Path
|
||||
- name: logSuccessfulMavenTransfers
|
||||
type: bool
|
||||
description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
default: false
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/logSuccessfulMavenTransfers
|
||||
|
||||
containers:
|
||||
- name: mvn
|
||||
image: maven:3.6-jdk-8
|
||||
imagePullPolicy: Never
|
||||
|
@ -13,27 +13,6 @@ spec:
|
||||
- PARAMETERS
|
||||
- STEPS
|
||||
mandatory: false
|
||||
- name: projectSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as project settings file.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STEPS
|
||||
mandatory: false
|
||||
- name: globalSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as global settings file.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STEPS
|
||||
mandatory: false
|
||||
- name: m2Path
|
||||
type: string
|
||||
description: Path to the location of the local repository that should be used.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STEPS
|
||||
mandatory: false
|
||||
- name: goals
|
||||
type: "[]string"
|
||||
description: Maven goals that should be executed.
|
||||
@ -53,16 +32,60 @@ spec:
|
||||
- PARAMETERS
|
||||
- STEPS
|
||||
mandatory: false
|
||||
- name: logSuccessfulMavenTransfers
|
||||
type: bool
|
||||
description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
default: false
|
||||
mandatory: false
|
||||
- name: returnStdout
|
||||
type: bool
|
||||
description: Returns the output of the maven command for further processing.
|
||||
scope:
|
||||
- PARAMETERS
|
||||
default: false
|
||||
|
||||
# Global maven settings, should be added to all maven steps
|
||||
- name: projectSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as project settings file.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/projectSettingsFile
|
||||
- name: globalSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as global settings file.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/globalSettingsFile
|
||||
- name: m2Path
|
||||
type: string
|
||||
description: Path to the location of the local repository that should be used.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/m2Path
|
||||
- name: logSuccessfulMavenTransfers
|
||||
type: bool
|
||||
description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
default: false
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/logSuccessfulMavenTransfers
|
||||
containers:
|
||||
- name: mvn
|
||||
image: maven:3.6-jdk-8
|
||||
imagePullPolicy: Never
|
||||
|
@ -69,6 +69,54 @@ spec:
|
||||
- STEPS
|
||||
aliases:
|
||||
- name: pmd/ruleSets
|
||||
|
||||
# Global maven settings, should be added to all maven steps
|
||||
- name: projectSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as project settings file.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/projectSettingsFile
|
||||
- name: globalSettingsFile
|
||||
type: string
|
||||
description: Path to the mvn settings file that should be used as global settings file.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/globalSettingsFile
|
||||
- name: m2Path
|
||||
type: string
|
||||
description: Path to the location of the local repository that should be used.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/m2Path
|
||||
- name: logSuccessfulMavenTransfers
|
||||
type: bool
|
||||
description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
|
||||
scope:
|
||||
- GENERAL
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
default: false
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: maven/logSuccessfulMavenTransfers
|
||||
|
||||
containers:
|
||||
- name: mvn
|
||||
image: maven:3.6-jdk-8
|
||||
|
Loading…
x
Reference in New Issue
Block a user