Skip to content

Commit

Permalink
Merge pull request #41 from fumikony/codebuild-envvar
Browse files Browse the repository at this point in the history
fix environment variable for CodeBuild
  • Loading branch information
b4b4r07 authored Jul 30, 2019
2 parents 189a71f + cfd888e commit 674833f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func travisci() (ci CI, err error) {
func codebuild() (ci CI, err error) {
ci.PR.Number = 0
ci.PR.Revision = os.Getenv("CODEBUILD_RESOLVED_SOURCE_VERSION")
ci.URL = os.Getenv("CODEBUILD_AGENT_ENV_CODEBUILD_BUILD_URL")
ci.URL = os.Getenv("CODEBUILD_BUILD_URL")
sourceVersion := os.Getenv("CODEBUILD_SOURCE_VERSION")
if sourceVersion == "" {
return ci, nil
Expand Down
10 changes: 5 additions & 5 deletions ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestCodeBuild(t *testing.T) {
envs := []string{
"CODEBUILD_RESOLVED_SOURCE_VERSION",
"CODEBUILD_SOURCE_VERSION",
"CODEBUILD_AGENT_ENV_CODEBUILD_BUILD_URL",
"CODEBUILD_BUILD_URL",
}
saveEnvs := make(map[string]string)
for _, key := range envs {
Expand All @@ -237,7 +237,7 @@ func TestCodeBuild(t *testing.T) {
fn: func() {
os.Setenv("CODEBUILD_RESOLVED_SOURCE_VERSION", "abcdefg")
os.Setenv("CODEBUILD_SOURCE_VERSION", "pr/123")
os.Setenv("CODEBUILD_AGENT_ENV_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")
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{
Expand All @@ -252,7 +252,7 @@ func TestCodeBuild(t *testing.T) {
fn: func() {
os.Setenv("CODEBUILD_RESOLVED_SOURCE_VERSION", "abcdefg")
os.Setenv("CODEBUILD_SOURCE_VERSION", "pr/1")
os.Setenv("CODEBUILD_AGENT_ENV_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")
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{
Expand All @@ -267,7 +267,7 @@ func TestCodeBuild(t *testing.T) {
fn: func() {
os.Setenv("CODEBUILD_RESOLVED_SOURCE_VERSION", "")
os.Setenv("CODEBUILD_SOURCE_VERSION", "")
os.Setenv("CODEBUILD_AGENT_ENV_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")
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{
Expand All @@ -282,7 +282,7 @@ func TestCodeBuild(t *testing.T) {
fn: func() {
os.Setenv("CODEBUILD_RESOLVED_SOURCE_VERSION", "")
os.Setenv("CODEBUILD_SOURCE_VERSION", "pr/abc")
os.Setenv("CODEBUILD_AGENT_ENV_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")
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{
Expand Down

0 comments on commit 674833f

Please sign in to comment.