1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-07-15 01:34:38 +02:00

feat: support cpe credentials for multiple repos (#3641)

This commit is contained in:
Oliver Nocon
2022-03-17 08:01:00 +01:00
committed by GitHub
parent 4208bc050c
commit 504f076613
20 changed files with 167 additions and 3 deletions

View File

@ -176,6 +176,11 @@ func containerSaveImageMetadata() config.StepData {
{
Name: "containerRegistryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -190,6 +195,11 @@ func containerSaveImageMetadata() config.StepData {
{
Name: "containerRegistryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -362,6 +362,11 @@ func golangBuildMetadata() config.StepData {
{
Name: "targetRepositoryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/rawRepositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -376,6 +381,11 @@ func golangBuildMetadata() config.StepData {
{
Name: "targetRepositoryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/rawRepositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",
@ -390,6 +400,11 @@ func golangBuildMetadata() config.StepData {
{
Name: "targetRepositoryURL",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/rawRepositoryURL",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUrl",

View File

@ -239,6 +239,11 @@ func helmExecuteMetadata() config.StepData {
Type: "secret",
},
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -296,6 +301,11 @@ func helmExecuteMetadata() config.StepData {
Type: "secret",
},
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -264,6 +264,11 @@ func kubernetesDeployMetadata() config.StepData {
Type: "secret",
},
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -321,6 +326,11 @@ func kubernetesDeployMetadata() config.StepData {
Type: "secret",
},
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -244,6 +244,11 @@ func malwareExecuteScanMetadata() config.StepData {
{
Name: "containerRegistryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -258,6 +263,11 @@ func malwareExecuteScanMetadata() config.StepData {
{
Name: "containerRegistryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -363,6 +363,11 @@ func mavenBuildMetadata() config.StepData {
{
Name: "altDeploymentRepositoryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -388,6 +393,11 @@ func mavenBuildMetadata() config.StepData {
{
Name: "altDeploymentRepositoryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",
@ -402,6 +412,11 @@ func mavenBuildMetadata() config.StepData {
{
Name: "altDeploymentRepositoryUrl",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryURL",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUrl",

View File

@ -381,6 +381,11 @@ func mtaBuildMetadata() config.StepData {
{
Name: "mtaDeploymentRepositoryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -406,6 +411,11 @@ func mtaBuildMetadata() config.StepData {
{
Name: "mtaDeploymentRepositoryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",
@ -420,6 +430,11 @@ func mtaBuildMetadata() config.StepData {
{
Name: "mtaDeploymentRepositoryUrl",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/mavenRepositoryURL",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUrl",

View File

@ -330,6 +330,11 @@ func npmExecuteScriptsMetadata() config.StepData {
{
Name: "repositoryUrl",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/npmRepositoryURL",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUrl",
@ -344,6 +349,11 @@ func npmExecuteScriptsMetadata() config.StepData {
{
Name: "repositoryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/npmRepositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -358,6 +368,11 @@ func npmExecuteScriptsMetadata() config.StepData {
{
Name: "repositoryUsername",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "custom/npmRepositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -346,7 +346,7 @@ func addWhitesourceExecuteScanFlags(cmd *cobra.Command, stepConfig *whitesourceE
cmd.Flags().BoolVar(&stepConfig.InstallArtifacts, "installArtifacts", false, "If enabled, it will install all artifacts to the local maven repository to make them available before running whitesource. This is required if any maven module has dependencies to other modules in the repository and they were not installed before.")
cmd.Flags().StringVar(&stepConfig.DefaultNpmRegistry, "defaultNpmRegistry", os.Getenv("PIPER_defaultNpmRegistry"), "URL of the npm registry to use. Defaults to https://registry.npmjs.org/")
cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line")
cmd.Flags().BoolVar(&stepConfig.CreateResultIssue, "createResultIssue", false, "Whether the step creates a GitHub issue containing the scan results in the originating repo. Since optimized pipelines are headless the creation is implicitly activated for scheduled runs.")
cmd.Flags().BoolVar(&stepConfig.CreateResultIssue, "createResultIssue", false, "Activate creation of a result issue in GitHub.")
cmd.Flags().StringVar(&stepConfig.GithubAPIURL, "githubApiUrl", `https://api.github.com`, "Set the GitHub API URL.")
cmd.Flags().StringVar(&stepConfig.Owner, "owner", os.Getenv("PIPER_owner"), "Set the GitHub organization.")
cmd.Flags().StringVar(&stepConfig.Repository, "repository", os.Getenv("PIPER_repository"), "Set the GitHub repository.")
@ -469,6 +469,11 @@ func whitesourceExecuteScanMetadata() config.StepData {
{
Name: "containerRegistryPassword",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryPassword",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryPassword",
@ -483,6 +488,11 @@ func whitesourceExecuteScanMetadata() config.StepData {
{
Name: "containerRegistryUser",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "container/repositoryUsername",
},
{
Name: "commonPipelineEnvironment",
Param: "custom/repositoryUsername",

View File

@ -369,6 +369,7 @@ func (m *StepData) GetResourceParameters(path, name string) map[string]interface
if val := getParameterValue(path, res, param); val != nil {
resourceParams[param.Name] = val
}
break
}
}
}

View File

@ -650,6 +650,13 @@ func TestGetResourceParameters(t *testing.T) {
}}}},
expected: map[string]interface{}{"param4": "{\"key\":\"valueString\"}"},
},
{
in: StepData{
Spec: StepSpec{Inputs: StepInputs{Parameters: []StepParameters{
{Name: "param1", ResourceRef: []ResourceReference{{Name: "commonPipelineEnvironment", Param: "envparam1"}, {Name: "commonPipelineEnvironment", Param: "envparam2"}}, Type: "string"},
}}}},
expected: map[string]interface{}{"param1": "val1"},
},
}
dir, err := ioutil.TempDir("", "")

View File

@ -53,6 +53,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: containerRegistryUser
@ -64,6 +66,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: filePath

View File

@ -118,6 +118,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/rawRepositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: targetRepositoryUser
@ -129,6 +131,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/rawRepositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: targetRepositoryURL
@ -139,6 +143,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/rawRepositoryURL
- name: commonPipelineEnvironment
param: custom/repositoryUrl
- name: reportCoverage

View File

@ -68,6 +68,8 @@ spec:
- name: dockerCredentialsId
type: secret
param: password
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: containerImageName
@ -119,6 +121,8 @@ spec:
- name: dockerCredentialsId
type: secret
param: username
- name: commonPipelineEnvironment
param: container/repositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: containerRegistrySecret

View File

@ -147,6 +147,8 @@ spec:
- name: dockerCredentialsId
type: secret
param: password
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: containerImageName
@ -198,6 +200,8 @@ spec:
- name: dockerCredentialsId
type: secret
param: username
- name: commonPipelineEnvironment
param: container/repositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: containerRegistrySecret

View File

@ -47,6 +47,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: containerRegistryUser
@ -58,6 +60,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: host

View File

@ -148,6 +148,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: altDeploymentRepositoryPasswordId
@ -164,6 +166,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: altDeploymentRepositoryUrl
@ -175,6 +179,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryURL
- name: commonPipelineEnvironment
param: custom/repositoryUrl
- name: altDeploymentRepositoryID

View File

@ -164,6 +164,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: mtaDeploymentRepositoryPasswordId
@ -180,6 +182,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: mtaDeploymentRepositoryUrl
@ -191,6 +195,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenRepositoryURL
- name: commonPipelineEnvironment
param: custom/repositoryUrl
- name: publish

View File

@ -105,6 +105,8 @@ spec:
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/npmRepositoryURL
- name: commonPipelineEnvironment
param: custom/repositoryUrl
- name: repositoryPassword
@ -117,6 +119,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/npmRepositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: repositoryUsername
@ -129,6 +133,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/npmRepositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: buildSettingsInfo

View File

@ -125,6 +125,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: containerRegistryUser
@ -136,6 +138,8 @@ spec:
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryUsername
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: createProductFromPipeline
@ -514,8 +518,10 @@ spec:
name: githubVaultSecretName
- name: createResultIssue
type: bool
description: "Whether the step creates a GitHub issue containing the scan results in the originating repo.
Since optimized pipelines are headless the creation is implicitly activated for scheduled runs."
description: Activate creation of a result issue in GitHub.
longDescription: |
Whether the step creates a GitHub issue containing the scan results in the originating repo.
Since optimized pipelines are headless the creation is implicitly activated for scheduled runs.
resourceRef:
- name: commonPipelineEnvironment
param: custom/optimizedAndScheduled