Skip to content

Commit

Permalink
fix(api): git.server not send to children (#4181)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored Apr 11, 2019
1 parent 6ae1ff0 commit d18d84d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions engine/api/workflow/process_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func processNode(ctx context.Context, db gorp.SqlExecutor, store cache.Store, pr
if isRoot || currentRepo == "" || (parentRepo != nil && parentRepo.Value == currentRepo) {
for _, param := range run.BuildParameters {
switch param.Name {
case tagGitHash, tagGitBranch, tagGitTag, tagGitAuthor, tagGitMessage, tagGitRepository, tagGitURL, tagGitHTTPURL:
case tagGitHash, tagGitBranch, tagGitTag, tagGitAuthor, tagGitMessage, tagGitRepository, tagGitURL, tagGitHTTPURL, tagGitServer:
currentJobGitValues[param.Name] = param.Value
}
}
Expand All @@ -209,7 +209,7 @@ func processNode(ctx context.Context, db gorp.SqlExecutor, store cache.Store, pr
// copy git info from ancestors
for _, param := range parent[0].BuildParameters {
switch param.Name {
case tagGitHash, tagGitBranch, tagGitTag, tagGitAuthor, tagGitMessage, tagGitRepository, tagGitURL, tagGitHTTPURL:
case tagGitHash, tagGitBranch, tagGitTag, tagGitAuthor, tagGitMessage, tagGitRepository, tagGitURL, tagGitHTTPURL, tagGitServer:
currentJobGitValues[param.Name] = param.Value
}
}
Expand Down Expand Up @@ -286,6 +286,7 @@ func processNode(ctx context.Context, db gorp.SqlExecutor, store cache.Store, pr
vcsInf.Message = currentJobGitValues[tagGitMessage]
vcsInf.URL = currentJobGitValues[tagGitURL]
vcsInf.HTTPUrl = currentJobGitValues[tagGitHTTPURL]
vcsInf.Server = currentJobGitValues[tagGitServer]
}

// Update datas if repo change
Expand Down
5 changes: 5 additions & 0 deletions engine/api/workflow/process_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,18 +816,21 @@ func TestManualRunBuildParameterMultiApplication(t *testing.T) {
assert.Equal(t, "mylastcommit", mapParams["git.hash"])
assert.Equal(t, "steven.guiheux", mapParams["git.author"])
assert.Equal(t, "super commit", mapParams["git.message"])
assert.Equal(t, "github", wr.WorkflowNodeRuns[w.WorkflowData.Node.ID][0].VCSServer)

mapParams2 := sdk.ParametersToMap(wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.ID][0].BuildParameters)
assert.Equal(t, "defaultBranch", mapParams2["git.branch"])
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, "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, "github", wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.Triggers[0].ChildNode.ID][0].VCSServer)
}

// Payload: branch only
Expand Down Expand Up @@ -1347,6 +1350,7 @@ func TestGitParamOn2ApplicationSameRepo(t *testing.T) {
assert.Equal(t, "super commit", mapParams2["git.message"])
assert.Equal(t, "bar", mapParams2["my.value"])
assert.Equal(t, "build", mapParams2["workflow.root.pipeline"])
assert.Equal(t, "github", wr.WorkflowNodeRuns[w.WorkflowData.Node.Triggers[0].ChildNode.ID][0].VCSServer)

}

Expand Down Expand Up @@ -1550,6 +1554,7 @@ func TestGitParamWithJoin(t *testing.T) {
assert.Equal(t, "bar", mapParams2["my.value"])
assert.Equal(t, "build", mapParams2["workflow.root.pipeline"])
assert.Equal(t, "join", mapParams2["workflow.join.node"])
assert.Equal(t, "feat/branch", wr.WorkflowNodeRuns[w.WorkflowData.Joins[0].Triggers[0].ChildNode.ID][0].VCSBranch)
}

// Payload: branch only
Expand Down
1 change: 1 addition & 0 deletions engine/api/workflow/run_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
tagGitMessage = "git.message"
tagGitURL = "git.url"
tagGitHTTPURL = "git.http_url"
tagGitServer = "git.server"
)

//RunFromHook is the entry point to trigger a workflow from a hook
Expand Down

0 comments on commit d18d84d

Please sign in to comment.