Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1521 from chavafg/topic/checkcommits-stable1.5
Browse files Browse the repository at this point in the history
checkcommits: recognize jenkins CI environment
  • Loading branch information
ganeshmaharaj authored May 3, 2019
2 parents 743347e + acbc236 commit ac41cf9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/checkcommits/checkcommits.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func getCommitRange(commit, branch string) ([]string, error) {
args = append(args, "rev-list")
args = append(args, "--no-merges")
args = append(args, "--reverse")
args = append(args, fmt.Sprintf("%s..%s", branch, commit))
args = append(args, fmt.Sprintf("origin/%s..%s", branch, commit))

return runCommand(args)
}
Expand Down Expand Up @@ -467,6 +467,13 @@ func detectCIEnvironment() (commit, dstBranch, srcBranch string) {
// contains that branch: master doesn't exist.
dstBranch = "origin"
}
} else if os.Getenv("ghprbPullId") != "" {
name = "JenkinsCI - github pull request builder"

commit = os.Getenv("ghprbActualCommit")

srcBranch = os.Getenv("ghprbSourceBranch")
dstBranch = os.Getenv("ghprbTargetBranch")
}

if verbose && name != "" {
Expand Down
5 changes: 5 additions & 0 deletions cmd/checkcommits/checkcommits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ func clearCIVariables() {
"REVISION",
"BRANCH_NAME",
"PULL_REQUEST_NUMBER",

"ghprbPullId",
"ghprbActualCommit",
"ghprbSourceBranch",
"ghprbTargetBranch",
}

for _, envVar := range envVars {
Expand Down

0 comments on commit ac41cf9

Please sign in to comment.