github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/cmd/artifactPrepareVersion_generated.go (about)

     1  // Code generated by piper's step-generator. DO NOT EDIT.
     2  
     3  package cmd
     4  
     5  import (
     6  	"fmt"
     7  	"os"
     8  	"path/filepath"
     9  	"time"
    10  
    11  	"github.com/SAP/jenkins-library/pkg/config"
    12  	"github.com/SAP/jenkins-library/pkg/log"
    13  	"github.com/SAP/jenkins-library/pkg/piperenv"
    14  	"github.com/SAP/jenkins-library/pkg/splunk"
    15  	"github.com/SAP/jenkins-library/pkg/telemetry"
    16  	"github.com/SAP/jenkins-library/pkg/validation"
    17  	"github.com/spf13/cobra"
    18  )
    19  
    20  type artifactPrepareVersionOptions struct {
    21  	AdditionalTargetTools       []string `json:"additionalTargetTools,omitempty" validate:"possible-values=custom docker dub golang gradle helm maven mta npm pip sbt yarn"`
    22  	AdditionalTargetDescriptors []string `json:"additionalTargetDescriptors,omitempty"`
    23  	BuildTool                   string   `json:"buildTool,omitempty" validate:"possible-values=custom docker dub golang gradle helm maven mta npm pip sbt yarn"`
    24  	CommitUserName              string   `json:"commitUserName,omitempty"`
    25  	CustomVersionField          string   `json:"customVersionField,omitempty"`
    26  	CustomVersionSection        string   `json:"customVersionSection,omitempty"`
    27  	CustomVersioningScheme      string   `json:"customVersioningScheme,omitempty" validate:"possible-values=docker maven pep440 semver2"`
    28  	DockerVersionSource         string   `json:"dockerVersionSource,omitempty"`
    29  	FetchCoordinates            bool     `json:"fetchCoordinates,omitempty"`
    30  	FilePath                    string   `json:"filePath,omitempty"`
    31  	GlobalSettingsFile          string   `json:"globalSettingsFile,omitempty"`
    32  	IncludeCommitID             bool     `json:"includeCommitId,omitempty"`
    33  	IsOptimizedAndScheduled     bool     `json:"isOptimizedAndScheduled,omitempty"`
    34  	M2Path                      string   `json:"m2Path,omitempty"`
    35  	Password                    string   `json:"password,omitempty"`
    36  	ProjectSettingsFile         string   `json:"projectSettingsFile,omitempty"`
    37  	ShortCommitID               bool     `json:"shortCommitId,omitempty"`
    38  	TagPrefix                   string   `json:"tagPrefix,omitempty"`
    39  	UnixTimestamp               bool     `json:"unixTimestamp,omitempty"`
    40  	Username                    string   `json:"username,omitempty"`
    41  	VersioningTemplate          string   `json:"versioningTemplate,omitempty"`
    42  	VersioningType              string   `json:"versioningType,omitempty" validate:"possible-values=cloud cloud_noTag library"`
    43  	CustomTLSCertificateLinks   []string `json:"customTlsCertificateLinks,omitempty"`
    44  }
    45  
    46  type artifactPrepareVersionCommonPipelineEnvironment struct {
    47  	artifactVersion         string
    48  	originalArtifactVersion string
    49  	artifactID              string
    50  	groupID                 string
    51  	packaging               string
    52  	git                     struct {
    53  		commitID      string
    54  		headCommitID  string
    55  		commitMessage string
    56  	}
    57  }
    58  
    59  func (p *artifactPrepareVersionCommonPipelineEnvironment) persist(path, resourceName string) {
    60  	content := []struct {
    61  		category string
    62  		name     string
    63  		value    interface{}
    64  	}{
    65  		{category: "", name: "artifactVersion", value: p.artifactVersion},
    66  		{category: "", name: "originalArtifactVersion", value: p.originalArtifactVersion},
    67  		{category: "", name: "artifactId", value: p.artifactID},
    68  		{category: "", name: "groupId", value: p.groupID},
    69  		{category: "", name: "packaging", value: p.packaging},
    70  		{category: "git", name: "commitId", value: p.git.commitID},
    71  		{category: "git", name: "headCommitId", value: p.git.headCommitID},
    72  		{category: "git", name: "commitMessage", value: p.git.commitMessage},
    73  	}
    74  
    75  	errCount := 0
    76  	for _, param := range content {
    77  		err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(param.category, param.name), param.value)
    78  		if err != nil {
    79  			log.Entry().WithError(err).Error("Error persisting piper environment.")
    80  			errCount++
    81  		}
    82  	}
    83  	if errCount > 0 {
    84  		log.Entry().Error("failed to persist Piper environment")
    85  	}
    86  }
    87  
    88  // ArtifactPrepareVersionCommand Prepares and potentially updates the artifact's version before building the artifact.
    89  func ArtifactPrepareVersionCommand() *cobra.Command {
    90  	const STEP_NAME = "artifactPrepareVersion"
    91  
    92  	metadata := artifactPrepareVersionMetadata()
    93  	var stepConfig artifactPrepareVersionOptions
    94  	var startTime time.Time
    95  	var commonPipelineEnvironment artifactPrepareVersionCommonPipelineEnvironment
    96  	var logCollector *log.CollectorHook
    97  	var splunkClient *splunk.Splunk
    98  	telemetryClient := &telemetry.Telemetry{}
    99  
   100  	var createArtifactPrepareVersionCmd = &cobra.Command{
   101  		Use:   STEP_NAME,
   102  		Short: "Prepares and potentially updates the artifact's version before building the artifact.",
   103  		Long: `Prepares and potentially updates the artifact's version before building the artifact.
   104  
   105  The continuous delivery process requires that each build is done with a unique version number.
   106  There are two common patterns found:
   107  
   108  ### 1. Continuous Deployment pattern with automatic versioning
   109  
   110  The team has full authority on ` + "`" + `<major>.<minor>.<patch>` + "`" + ` and can increase any part whenever required.
   111  Nonetheless, the automatic versioning makes sure that every build will create a unique version by appending ` + "`" + `<major>.<minor>.<patch>` + "`" + ` with a buildversion (we use a timestamp) and optionally the commitId.
   112  
   113  In order to represent this version also in the version control system the new unique version will be pushed with a dedicated tag (` + "`" + `<tagPrefix><major>.<minor>.<patch><unique extension>` + "`" + `).
   114  
   115  Depending on the build tool used and thus the allowed versioning format the ` + "`" + `<unique extension>` + "`" + ` varies.
   116  
   117  **Remarks:**
   118  
   119  * There is no commit to master since this would create a perpetuum mobile and just trigger the next automatic build with automatic versioning, and so on ...
   120  * Not creating a tag would lead to a loss of the final artifact version in scm which often is not acceptable
   121  * You need to ensure that your CI/CD system can push back to your SCM (via providing ssh or HTTP(s) credentials)
   122  
   123  **This pattern is the default** behavior (` + "`" + `versioningType: cloud` + "`" + `) since this is suitable for most cloud deliveries.
   124  
   125  It is possible to use ` + "`" + `versioningType: cloud_noTag` + "`" + ` which has a slightly different behavior than described above:
   126  
   127  * The new version will NOT be written as tag into the SCM but it is only available in the corresponding CI/CD workspace
   128  * IMPORTANT NOTICE: Using the option ` + "`" + `cloud_noTag` + "`" + ` should not be picked in case you need to ensure a fully traceable path from SCM commit to your build artifact.
   129  
   130  ### 2. Pure version ` + "`" + `<major>.<minor>.<patch>` + "`" + `
   131  
   132  This pattern is often used by teams that have cloud deliveries with no fully automated procedure, e.g. delivery after each takt.
   133  Another typical use-case is development of a library with regular releases where the versioning pattern should be consumable and thus ideally complies to a ` + "`" + `<major>.<minor>.<patch>` + "`" + ` pattern.
   134  
   135  The version is then either manually set by the team in the course of the development process or automatically pushed to master after a successful release.
   136  
   137  Unlike for the _Continuous Deloyment_ pattern described above, in this case there is no dedicated tagging required for the build process since the version is already available in the repository.
   138  
   139  Configuration of this pattern is done via ` + "`" + `versioningType: library` + "`" + `.
   140  
   141  ### Support of additional build tools
   142  
   143  Besides the ` + "`" + `buildTools` + "`" + ` provided out of the box (like ` + "`" + `maven` + "`" + `, ` + "`" + `mta` + "`" + `, ` + "`" + `npm` + "`" + `, ...) it is possible to set ` + "`" + `buildTool: custom` + "`" + `.
   144  
   145  This allows you to provide automatic versioning for tools using a:
   146  
   147  #### file with the version as only content:
   148  
   149  Define ` + "`" + `buildTool: custom` + "`" + ` as well as ` + "`" + `filePath: <path to your file>` + "`" + `
   150  
   151  **Please note:** ` + "`" + `<path to your file>` + "`" + ` need to point either to a ` + "`" + `*.txt` + "`" + ` file or to a file without extension.
   152  
   153  #### ` + "`" + `ini` + "`" + ` file containing the version:
   154  
   155  Define ` + "`" + `buildTool: custom` + "`" + `, ` + "`" + `filePath: <path to your ini-file>` + "`" + ` as well as parameters ` + "`" + `versionSection` + "`" + ` and ` + "`" + `versionSource` + "`" + ` to point to the version location (section & parameter name) within the file.
   156  
   157  **Please note:** ` + "`" + `<path to your file>` + "`" + ` need to point either to a ` + "`" + `*.cfg` + "`" + ` or a ` + "`" + `*.ini` + "`" + ` file.
   158  
   159  #### ` + "`" + `json` + "`" + ` file containing the version:
   160  
   161  Define ` + "`" + `buildTool: custom` + "`" + `, ` + "`" + `filePath: <path to your *.json file` + "`" + ` as well as parameter ` + "`" + `versionSource` + "`" + ` to point to the parameter containing the version.
   162  
   163  #### ` + "`" + `yaml` + "`" + ` file containing the version
   164  
   165  Define ` + "`" + `buildTool: custom` + "`" + `, ` + "`" + `filePath: <path to your *.yml/*.yaml file` + "`" + ` as well as parameter ` + "`" + `versionSource` + "`" + ` to point to the parameter containing the version.`,
   166  		PreRunE: func(cmd *cobra.Command, _ []string) error {
   167  			startTime = time.Now()
   168  			log.SetStepName(STEP_NAME)
   169  			log.SetVerbose(GeneralConfig.Verbose)
   170  
   171  			GeneralConfig.GitHubAccessTokens = ResolveAccessTokens(GeneralConfig.GitHubTokens)
   172  
   173  			path, _ := os.Getwd()
   174  			fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path}
   175  			log.RegisterHook(fatalHook)
   176  
   177  			err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile)
   178  			if err != nil {
   179  				log.SetErrorCategory(log.ErrorConfiguration)
   180  				return err
   181  			}
   182  			log.RegisterSecret(stepConfig.Password)
   183  			log.RegisterSecret(stepConfig.Username)
   184  
   185  			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
   186  				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
   187  				log.RegisterHook(&sentryHook)
   188  			}
   189  
   190  			if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   191  				splunkClient = &splunk.Splunk{}
   192  				logCollector = &log.CollectorHook{CorrelationID: GeneralConfig.CorrelationID}
   193  				log.RegisterHook(logCollector)
   194  			}
   195  
   196  			if err = log.RegisterANSHookIfConfigured(GeneralConfig.CorrelationID); err != nil {
   197  				log.Entry().WithError(err).Warn("failed to set up SAP Alert Notification Service log hook")
   198  			}
   199  
   200  			validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages())
   201  			if err != nil {
   202  				return err
   203  			}
   204  			if err = validation.ValidateStruct(stepConfig); err != nil {
   205  				log.SetErrorCategory(log.ErrorConfiguration)
   206  				return err
   207  			}
   208  
   209  			return nil
   210  		},
   211  		Run: func(_ *cobra.Command, _ []string) {
   212  			stepTelemetryData := telemetry.CustomData{}
   213  			stepTelemetryData.ErrorCode = "1"
   214  			handler := func() {
   215  				commonPipelineEnvironment.persist(GeneralConfig.EnvRootPath, "commonPipelineEnvironment")
   216  				config.RemoveVaultSecretFiles()
   217  				stepTelemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds())
   218  				stepTelemetryData.ErrorCategory = log.GetErrorCategory().String()
   219  				stepTelemetryData.PiperCommitHash = GitCommit
   220  				telemetryClient.SetData(&stepTelemetryData)
   221  				telemetryClient.Send()
   222  				if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   223  					splunkClient.Initialize(GeneralConfig.CorrelationID,
   224  						GeneralConfig.HookConfig.SplunkConfig.Dsn,
   225  						GeneralConfig.HookConfig.SplunkConfig.Token,
   226  						GeneralConfig.HookConfig.SplunkConfig.Index,
   227  						GeneralConfig.HookConfig.SplunkConfig.SendLogs)
   228  					splunkClient.Send(telemetryClient.GetData(), logCollector)
   229  				}
   230  				if len(GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint) > 0 {
   231  					splunkClient.Initialize(GeneralConfig.CorrelationID,
   232  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint,
   233  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblToken,
   234  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblIndex,
   235  						GeneralConfig.HookConfig.SplunkConfig.SendLogs)
   236  					splunkClient.Send(telemetryClient.GetData(), logCollector)
   237  				}
   238  			}
   239  			log.DeferExitHandler(handler)
   240  			defer handler()
   241  			telemetryClient.Initialize(GeneralConfig.NoTelemetry, STEP_NAME)
   242  			artifactPrepareVersion(stepConfig, &stepTelemetryData, &commonPipelineEnvironment)
   243  			stepTelemetryData.ErrorCode = "0"
   244  			log.Entry().Info("SUCCESS")
   245  		},
   246  	}
   247  
   248  	addArtifactPrepareVersionFlags(createArtifactPrepareVersionCmd, &stepConfig)
   249  	return createArtifactPrepareVersionCmd
   250  }
   251  
   252  func addArtifactPrepareVersionFlags(cmd *cobra.Command, stepConfig *artifactPrepareVersionOptions) {
   253  	cmd.Flags().StringSliceVar(&stepConfig.AdditionalTargetTools, "additionalTargetTools", []string{}, "Additional buildTool targets where descriptors need to be updated besides the main `buildTool`.")
   254  	cmd.Flags().StringSliceVar(&stepConfig.AdditionalTargetDescriptors, "additionalTargetDescriptors", []string{}, "Defines patterns for build descriptors which should be used for option [`additionalTargetTools`](additionaltargettools).")
   255  	cmd.Flags().StringVar(&stepConfig.BuildTool, "buildTool", os.Getenv("PIPER_buildTool"), "Defines the tool which is used for building the artifact.")
   256  	cmd.Flags().StringVar(&stepConfig.CommitUserName, "commitUserName", `Project Piper`, "Defines the user name which appears in version control for the versioning update (in case `versioningType: cloud`).")
   257  	cmd.Flags().StringVar(&stepConfig.CustomVersionField, "customVersionField", os.Getenv("PIPER_customVersionField"), "For `buildTool: custom`: Defines the field which contains the version in the descriptor file.")
   258  	cmd.Flags().StringVar(&stepConfig.CustomVersionSection, "customVersionSection", os.Getenv("PIPER_customVersionSection"), "For `buildTool: custom`: Defines the section for version retrieval in vase a *.ini/*.cfg file is used.")
   259  	cmd.Flags().StringVar(&stepConfig.CustomVersioningScheme, "customVersioningScheme", `maven`, "For `buildTool: custom`: Defines the versioning scheme to be used.")
   260  	cmd.Flags().StringVar(&stepConfig.DockerVersionSource, "dockerVersionSource", os.Getenv("PIPER_dockerVersionSource"), "For `buildTool: docker`: Defines the source of the version. Can be `FROM`, any supported _buildTool_ or an environment variable name.")
   261  	cmd.Flags().BoolVar(&stepConfig.FetchCoordinates, "fetchCoordinates", false, "If set to `true` the step will retreive artifact coordinates and store them in the common pipeline environment.")
   262  	cmd.Flags().StringVar(&stepConfig.FilePath, "filePath", os.Getenv("PIPER_filePath"), "Defines a custom path to the descriptor file. Build tool specific defaults are used (e.g. `maven: pom.xml`, `npm: package.json`, `mta: mta.yaml`).")
   263  	cmd.Flags().StringVar(&stepConfig.GlobalSettingsFile, "globalSettingsFile", os.Getenv("PIPER_globalSettingsFile"), "Maven only - Path to the mvn settings file that should be used as global settings file.")
   264  	cmd.Flags().BoolVar(&stepConfig.IncludeCommitID, "includeCommitId", true, "Defines if the automatically generated version (`versioningType: cloud`) should include the commit id hash.")
   265  	cmd.Flags().BoolVar(&stepConfig.IsOptimizedAndScheduled, "isOptimizedAndScheduled", false, "Whether the pipeline runs in optimized mode and the current execution is a scheduled one")
   266  	cmd.Flags().StringVar(&stepConfig.M2Path, "m2Path", os.Getenv("PIPER_m2Path"), "Maven only - Path to the location of the local repository that should be used.")
   267  	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password/token for git authentication.")
   268  	cmd.Flags().StringVar(&stepConfig.ProjectSettingsFile, "projectSettingsFile", os.Getenv("PIPER_projectSettingsFile"), "Maven only - Path to the mvn settings file that should be used as project settings file.")
   269  	cmd.Flags().BoolVar(&stepConfig.ShortCommitID, "shortCommitId", false, "Defines if a short version of the commitId should be used. GitHub format is used (first 7 characters).")
   270  	cmd.Flags().StringVar(&stepConfig.TagPrefix, "tagPrefix", `build_`, "Defines the prefix which is used for the git tag which is written during the versioning run (only `versioningType: cloud`).")
   271  	cmd.Flags().BoolVar(&stepConfig.UnixTimestamp, "unixTimestamp", false, "Defines if the Unix timestamp number should be used as build number instead of the standard date format.")
   272  	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User name for git authentication")
   273  	cmd.Flags().StringVar(&stepConfig.VersioningTemplate, "versioningTemplate", os.Getenv("PIPER_versioningTemplate"), "DEPRECATED: Defines the template for the automatic version which will be created")
   274  	cmd.Flags().StringVar(&stepConfig.VersioningType, "versioningType", `cloud`, "Defines the type of versioning")
   275  	cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List containing download links of custom TLS certificates. This is required to ensure trusted connections to registries with custom certificates.")
   276  
   277  	cmd.MarkFlagRequired("buildTool")
   278  }
   279  
   280  // retrieve step metadata
   281  func artifactPrepareVersionMetadata() config.StepData {
   282  	var theMetaData = config.StepData{
   283  		Metadata: config.StepMetadata{
   284  			Name:        "artifactPrepareVersion",
   285  			Aliases:     []config.Alias{{Name: "artifactSetVersion", Deprecated: false}, {Name: "setVersion", Deprecated: true}},
   286  			Description: "Prepares and potentially updates the artifact's version before building the artifact.",
   287  		},
   288  		Spec: config.StepSpec{
   289  			Inputs: config.StepInputs{
   290  				Secrets: []config.StepSecrets{
   291  					{Name: "gitHttpsCredentialsId", Description: "Jenkins 'Username with password' credentials ID containing username/password for http access to your git repository.", Type: "jenkins"},
   292  					{Name: "gitSshKeyCredentialsId", Description: "Jenkins 'SSH Username with private key' credentials ID ssh key for accessing your git repository. You can find details about how to generate an ssh key in the [GitHub documentation](https://docs.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).", Type: "jenkins", Aliases: []config.Alias{{Name: "gitCredentialsId", Deprecated: true}}},
   293  				},
   294  				Parameters: []config.StepParameters{
   295  					{
   296  						Name:        "additionalTargetTools",
   297  						ResourceRef: []config.ResourceReference{},
   298  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   299  						Type:        "[]string",
   300  						Mandatory:   false,
   301  						Aliases:     []config.Alias{},
   302  						Default:     []string{},
   303  					},
   304  					{
   305  						Name:        "additionalTargetDescriptors",
   306  						ResourceRef: []config.ResourceReference{},
   307  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   308  						Type:        "[]string",
   309  						Mandatory:   false,
   310  						Aliases:     []config.Alias{},
   311  						Default:     []string{},
   312  					},
   313  					{
   314  						Name:        "buildTool",
   315  						ResourceRef: []config.ResourceReference{},
   316  						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   317  						Type:        "string",
   318  						Mandatory:   true,
   319  						Aliases:     []config.Alias{},
   320  						Default:     os.Getenv("PIPER_buildTool"),
   321  					},
   322  					{
   323  						Name:        "commitUserName",
   324  						ResourceRef: []config.ResourceReference{},
   325  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   326  						Type:        "string",
   327  						Mandatory:   false,
   328  						Aliases:     []config.Alias{{Name: "gitUserName"}},
   329  						Default:     `Project Piper`,
   330  					},
   331  					{
   332  						Name:        "customVersionField",
   333  						ResourceRef: []config.ResourceReference{},
   334  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   335  						Type:        "string",
   336  						Mandatory:   false,
   337  						Aliases:     []config.Alias{},
   338  						Default:     os.Getenv("PIPER_customVersionField"),
   339  					},
   340  					{
   341  						Name:        "customVersionSection",
   342  						ResourceRef: []config.ResourceReference{},
   343  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   344  						Type:        "string",
   345  						Mandatory:   false,
   346  						Aliases:     []config.Alias{},
   347  						Default:     os.Getenv("PIPER_customVersionSection"),
   348  					},
   349  					{
   350  						Name:        "customVersioningScheme",
   351  						ResourceRef: []config.ResourceReference{},
   352  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   353  						Type:        "string",
   354  						Mandatory:   false,
   355  						Aliases:     []config.Alias{},
   356  						Default:     `maven`,
   357  					},
   358  					{
   359  						Name:        "dockerVersionSource",
   360  						ResourceRef: []config.ResourceReference{},
   361  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   362  						Type:        "string",
   363  						Mandatory:   false,
   364  						Aliases:     []config.Alias{},
   365  						Default:     os.Getenv("PIPER_dockerVersionSource"),
   366  					},
   367  					{
   368  						Name:        "fetchCoordinates",
   369  						ResourceRef: []config.ResourceReference{},
   370  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   371  						Type:        "bool",
   372  						Mandatory:   false,
   373  						Aliases:     []config.Alias{},
   374  						Default:     false,
   375  					},
   376  					{
   377  						Name:        "filePath",
   378  						ResourceRef: []config.ResourceReference{},
   379  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   380  						Type:        "string",
   381  						Mandatory:   false,
   382  						Aliases:     []config.Alias{},
   383  						Default:     os.Getenv("PIPER_filePath"),
   384  					},
   385  					{
   386  						Name:        "globalSettingsFile",
   387  						ResourceRef: []config.ResourceReference{},
   388  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   389  						Type:        "string",
   390  						Mandatory:   false,
   391  						Aliases:     []config.Alias{{Name: "maven/globalSettingsFile"}},
   392  						Default:     os.Getenv("PIPER_globalSettingsFile"),
   393  					},
   394  					{
   395  						Name:        "includeCommitId",
   396  						ResourceRef: []config.ResourceReference{},
   397  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   398  						Type:        "bool",
   399  						Mandatory:   false,
   400  						Aliases:     []config.Alias{},
   401  						Default:     true,
   402  					},
   403  					{
   404  						Name: "isOptimizedAndScheduled",
   405  						ResourceRef: []config.ResourceReference{
   406  							{
   407  								Name:  "commonPipelineEnvironment",
   408  								Param: "custom/isOptimizedAndScheduled",
   409  							},
   410  						},
   411  						Scope:     []string{"PARAMETERS"},
   412  						Type:      "bool",
   413  						Mandatory: false,
   414  						Aliases:   []config.Alias{},
   415  						Default:   false,
   416  					},
   417  					{
   418  						Name:        "m2Path",
   419  						ResourceRef: []config.ResourceReference{},
   420  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   421  						Type:        "string",
   422  						Mandatory:   false,
   423  						Aliases:     []config.Alias{{Name: "maven/m2Path"}},
   424  						Default:     os.Getenv("PIPER_m2Path"),
   425  					},
   426  					{
   427  						Name: "password",
   428  						ResourceRef: []config.ResourceReference{
   429  							{
   430  								Name:  "gitHttpsCredentialsId",
   431  								Param: "password",
   432  								Type:  "secret",
   433  							},
   434  
   435  							{
   436  								Name:    "gitHttpsCredentialVaultSecretName",
   437  								Type:    "vaultSecret",
   438  								Default: "gitHttpsCredential",
   439  							},
   440  						},
   441  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   442  						Type:      "string",
   443  						Mandatory: false,
   444  						Aliases:   []config.Alias{{Name: "access_token"}},
   445  						Default:   os.Getenv("PIPER_password"),
   446  					},
   447  					{
   448  						Name:        "projectSettingsFile",
   449  						ResourceRef: []config.ResourceReference{},
   450  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   451  						Type:        "string",
   452  						Mandatory:   false,
   453  						Aliases:     []config.Alias{{Name: "maven/projectSettingsFile"}},
   454  						Default:     os.Getenv("PIPER_projectSettingsFile"),
   455  					},
   456  					{
   457  						Name:        "shortCommitId",
   458  						ResourceRef: []config.ResourceReference{},
   459  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   460  						Type:        "bool",
   461  						Mandatory:   false,
   462  						Aliases:     []config.Alias{},
   463  						Default:     false,
   464  					},
   465  					{
   466  						Name:        "tagPrefix",
   467  						ResourceRef: []config.ResourceReference{},
   468  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   469  						Type:        "string",
   470  						Mandatory:   false,
   471  						Aliases:     []config.Alias{},
   472  						Default:     `build_`,
   473  					},
   474  					{
   475  						Name:        "unixTimestamp",
   476  						ResourceRef: []config.ResourceReference{},
   477  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   478  						Type:        "bool",
   479  						Mandatory:   false,
   480  						Aliases:     []config.Alias{},
   481  						Default:     false,
   482  					},
   483  					{
   484  						Name: "username",
   485  						ResourceRef: []config.ResourceReference{
   486  							{
   487  								Name:  "gitHttpsCredentialsId",
   488  								Param: "username",
   489  								Type:  "secret",
   490  							},
   491  
   492  							{
   493  								Name:    "gitHttpsCredentialVaultSecretName",
   494  								Type:    "vaultSecret",
   495  								Default: "gitHttpsCredential",
   496  							},
   497  						},
   498  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   499  						Type:      "string",
   500  						Mandatory: false,
   501  						Aliases:   []config.Alias{},
   502  						Default:   os.Getenv("PIPER_username"),
   503  					},
   504  					{
   505  						Name:        "versioningTemplate",
   506  						ResourceRef: []config.ResourceReference{},
   507  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   508  						Type:        "string",
   509  						Mandatory:   false,
   510  						Aliases:     []config.Alias{},
   511  						Default:     os.Getenv("PIPER_versioningTemplate"),
   512  					},
   513  					{
   514  						Name:        "versioningType",
   515  						ResourceRef: []config.ResourceReference{},
   516  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   517  						Type:        "string",
   518  						Mandatory:   false,
   519  						Aliases:     []config.Alias{},
   520  						Default:     `cloud`,
   521  					},
   522  					{
   523  						Name:        "customTlsCertificateLinks",
   524  						ResourceRef: []config.ResourceReference{},
   525  						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   526  						Type:        "[]string",
   527  						Mandatory:   false,
   528  						Aliases:     []config.Alias{},
   529  						Default:     []string{},
   530  						Conditions:  []config.Condition{{ConditionRef: "strings-equal", Params: []config.Param{{Name: "buildTool", Value: "maven"}, {Name: "buildTool", Value: "gradle"}}}},
   531  					},
   532  				},
   533  			},
   534  			Containers: []config.Container{
   535  				{Image: "maven:3.6-jdk-8", Conditions: []config.Condition{{ConditionRef: "strings-equal", Params: []config.Param{{Name: "buildTool", Value: "maven"}}}}},
   536  			},
   537  			Outputs: config.StepOutputs{
   538  				Resources: []config.StepResources{
   539  					{
   540  						Name: "commonPipelineEnvironment",
   541  						Type: "piperEnvironment",
   542  						Parameters: []map[string]interface{}{
   543  							{"name": "artifactVersion"},
   544  							{"name": "originalArtifactVersion"},
   545  							{"name": "artifactId"},
   546  							{"name": "groupId"},
   547  							{"name": "packaging"},
   548  							{"name": "git/commitId"},
   549  							{"name": "git/headCommitId"},
   550  							{"name": "git/commitMessage"},
   551  						},
   552  					},
   553  				},
   554  			},
   555  		},
   556  	}
   557  	return theMetaData
   558  }