diff --git a/ci.go b/ci.go index 85d25f1..fcc7679 100644 --- a/ci.go +++ b/ci.go @@ -57,6 +57,9 @@ func codebuild() (ci CI, err error) { if sourceVersion == "" { return ci, nil } + if !strings.HasPrefix(sourceVersion,"pr/") { + return ci, nil + } pr := strings.Replace(sourceVersion, "pr/", "", 1) if pr == "" { return ci, nil diff --git a/ci_test.go b/ci_test.go index a5c77c3..bbc6f0c 100644 --- a/ci_test.go +++ b/ci_test.go @@ -357,6 +357,21 @@ func TestCodeBuild(t *testing.T) { }, ok: false, }, + { + fn: func() { + os.Setenv("CODEBUILD_RESOLVED_SOURCE_VERSION", "") + os.Setenv("CODEBUILD_SOURCE_VERSION", "f3008ac30d28ac38ae2533c2b153f00041661f22") + os.Setenv("CODEBUILD_BUILD_URL", "https://ap-northeast-1.console.aws.amazon.com/codebuild/home?region=ap-northeast-1#/builds/test:f2ae4314-c2d6-4db6-83c2-eacbab1517b7/view/new") + }, + ci: CI{ + PR: PullRequest{ + Revision: "", + Number: 0, + }, + URL: "https://ap-northeast-1.console.aws.amazon.com/codebuild/home?region=ap-northeast-1#/builds/test:f2ae4314-c2d6-4db6-83c2-eacbab1517b7/view/new", + }, + ok: true, + }, } for _, testCase := range testCases {