feat: PAC - dynamically generate Pipeline target branch (#1636)

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
This commit is contained in:
Zbynek Roubalik 2023-03-22 14:15:53 +01:00 committed by GitHub
parent 85d3d0206e
commit c793fd4c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -27,6 +27,9 @@ const (
// S2I related properties
defaultS2iImageScriptsUrl = "image:///usr/libexec/s2i"
quarkusS2iImageScriptsUrl = "image:///usr/local/s2i"
// The branch or tag we are targeting with Pipelines (ie: main, refs/tags/*)
defaultPipelinesTargetBranch = "main"
)
type templateData struct {
@ -44,6 +47,9 @@ type templateData struct {
PvcName string
SecretName string
// The branch or tag we are targeting with Pipelines (ie: main, refs/tags/*)
PipelinesTargetBranch string
// Static entries
RepoUrl string
Revision string
@ -85,6 +91,11 @@ func createPipelineRunTemplate(f fn.Function) error {
contextDir = "."
}
pipelinesTargetBranch := f.Build.Git.Revision
if pipelinesTargetBranch == "" {
pipelinesTargetBranch = defaultPipelinesTargetBranch
}
buildEnvs := []string{}
if len(f.Build.BuildEnvs) == 0 {
buildEnvs = []string{"="}
@ -114,6 +125,8 @@ func createPipelineRunTemplate(f fn.Function) error {
PvcName: getPipelinePvcName(f),
SecretName: getPipelineSecretName(f),
PipelinesTargetBranch: pipelinesTargetBranch,
GitCloneTaskRef: taskGitCloneRef,
FuncBuildpacksTaskRef: taskFuncBuildpacksRef,
FuncS2iTaskRef: taskFuncS2iRef,

View File

@ -114,7 +114,7 @@ metadata:
pipelinesascode.tekton.dev/on-event: "[push]"
# The branch or tag we are targeting (ie: main, refs/tags/*)
pipelinesascode.tekton.dev/on-target-branch: "[main]"
pipelinesascode.tekton.dev/on-target-branch: "[{{.PipelinesTargetBranch}}]"
# Fetch the git-clone task from hub
pipelinesascode.tekton.dev/task: {{.GitCloneTaskRef}}

View File

@ -122,7 +122,7 @@ metadata:
pipelinesascode.tekton.dev/on-event: "[push]"
# The branch or tag we are targeting (ie: main, refs/tags/*)
pipelinesascode.tekton.dev/on-target-branch: "[main]"
pipelinesascode.tekton.dev/on-target-branch: "[{{.PipelinesTargetBranch}}]"
# Fetch the git-clone task from hub
pipelinesascode.tekton.dev/task: {{.GitCloneTaskRef}}