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