Skip to content

Commit

Permalink
fix(api): add git param with prefix for children (#4189)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored and richardlt committed Apr 15, 2019
1 parent 75cf412 commit 43798f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions engine/api/workflow/process_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,15 @@ func TestManualRunBuildParameterMultiApplication(t *testing.T) {
assert.Equal(t, "defaultCommit", mapParams2["git.hash"])
assert.Equal(t, "john.snow", mapParams2["git.author"])
assert.Equal(t, "super default commit", mapParams2["git.message"])
assert.Equal(t, "mylastcommit", mapParams2["workflow.root.git.hash"])
assert.Equal(t, "stash", wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.ID][0].VCSServer)

mapParams3 := sdk.ParametersToMap(wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.Triggers[0].ChildNode.ID][0].BuildParameters)
assert.Equal(t, "feat/branch", mapParams3["git.branch"])
assert.Equal(t, "mylastcommit", mapParams3["git.hash"])
assert.Equal(t, "steven.guiheux", mapParams3["git.author"])
assert.Equal(t, "super commit", mapParams3["git.message"])
assert.Equal(t, "defaultBranch", mapParams3["workflow.child1.git.branch"])
assert.Equal(t, "github", wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.Triggers[0].ChildNode.ID][0].VCSServer)
}

Expand Down
8 changes: 5 additions & 3 deletions engine/api/workflow/process_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func getParentParameters(w *sdk.WorkflowRun, nodeRuns []*sdk.WorkflowNodeRun) ([

parentParams := make([]sdk.Parameter, 0, len(parentNodeRun.BuildParameters))
for _, param := range parentNodeRun.BuildParameters {

prefix := "workflow." + nodeName + "."
if param.Name == "" || param.Name == "cds.semver" || param.Name == "cds.release.version" ||
strings.HasPrefix(param.Name, "cds.proj") ||
strings.HasPrefix(param.Name, "cds.version") || strings.HasPrefix(param.Name, "cds.run.number") ||
Expand All @@ -177,15 +177,17 @@ func getParentParameters(w *sdk.WorkflowRun, nodeRuns []*sdk.WorkflowNodeRun) ([
// We inherite git variables is there is more than one repositories in the whole workflow
if strings.HasPrefix(param.Name, "git.") {
parentParams = append(parentParams, param)

// Create parent param
param.Name = prefix + param.Name
parentParams = append(parentParams, param)
continue
}
if strings.HasPrefix(param.Name, "gerrit.") {
parentParams = append(parentParams, param)
continue
}

prefix := "workflow." + nodeName + "."

if param.Name == "payload" || strings.HasPrefix(param.Name, "cds.triggered") {
// keep p.Name as is
} else if strings.HasPrefix(param.Name, "cds.") {
Expand Down

0 comments on commit 43798f0

Please sign in to comment.