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