Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service/codebuild: Enable Github Enterprise Report Build Status #6929

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions aws/resource_aws_codebuild_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,9 @@ func expandProjectSourceData(data map[string]interface{}) codebuild.ProjectSourc
projectSource.Location = aws.String(data["location"].(string))
}

// Only valid for BITBUCKET and GITHUB source type, e.g.
// InvalidInputException: Source type GITHUB_ENTERPRISE does not support ReportBuildStatus
if sourceType == codebuild.SourceTypeBitbucket || sourceType == codebuild.SourceTypeGithub {
// Only valid for BITBUCKET, GITHUB, and GITHUB_ENTERPRISE source types, e.g.
// InvalidInputException: Source type NO_SOURCE does not support ReportBuildStatus
if sourceType == codebuild.SourceTypeBitbucket || sourceType == codebuild.SourceTypeGithub || sourceType == codebuild.SourceTypeGithubEnterprise {
projectSource.ReportBuildStatus = aws.Bool(data["report_build_status"].(bool))
}

Expand Down
61 changes: 57 additions & 4 deletions aws/resource_aws_codebuild_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,34 @@ func TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub(t *testing.T) {
})
}

func TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_codebuild_project.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeBuildProjectConfig_Source_ReportBuildStatus_GitHubEnterprise(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
resource.TestCheckResourceAttr(resourceName, "source.2964899175.report_build_status", "true"),
),
},
{
Config: testAccAWSCodeBuildProjectConfig_Source_ReportBuildStatus_GitHubEnterprise(rName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildProjectExists(resourceName, &project),
resource.TestCheckResourceAttr(resourceName, "source.553628638.report_build_status", "false"),
),
},
},
})
}

func TestAccAWSCodeBuildProject_Source_Type_Bitbucket(t *testing.T) {
var project codebuild.Project
rName := acctest.RandomWithPrefix("tf-acc-test")
Expand Down Expand Up @@ -1302,6 +1330,31 @@ resource "aws_codebuild_project" "test" {
`, rName, reportBuildStatus)
}

func testAccAWSCodeBuildProjectConfig_Source_ReportBuildStatus_GitHubEnterprise(rName string, reportBuildStatus bool) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
name = %q
service_role = "${aws_iam_role.test.arn}"

artifacts {
type = "NO_ARTIFACTS"
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "2"
type = "LINUX_CONTAINER"
}

source {
location = "https://example.com/organization/repository.git"
report_build_status = %t
type = "GITHUB_ENTERPRISE"
}
}
`, rName, reportBuildStatus)
}

func testAccAWSCodeBuildProjectConfig_Source_Type_Bitbucket(rName string) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
resource "aws_codebuild_project" "test" {
Expand Down Expand Up @@ -1438,8 +1491,8 @@ resource "aws_codebuild_project" "test" {
}

source {
type = "NO_SOURCE"
location = "%s"
type = "NO_SOURCE"
location = "%s"
buildspec = %q
}
}
Expand Down Expand Up @@ -1635,13 +1688,13 @@ resource "aws_codebuild_project" "test" {
secondary_sources {
location = "https://git-codecommit.region-id.amazonaws.com/v1/repos/second-repo-name"
type = "CODECOMMIT"
source_identifier = "secondarySource1"
source_identifier = "secondarySource1"
}

secondary_sources {
location = "https://git-codecommit.region-id.amazonaws.com/v1/repos/third-repo-name"
type = "CODECOMMIT"
source_identifier = "secondarySource2"
source_identifier = "secondarySource2"
}
}
`, rName)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/codebuild_project.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ The following arguments are supported:
* `git_clone_depth` - (Optional) Truncate git history to this many commits.
* `insecure_ssl` - (Optional) Ignore SSL warnings when connecting to source control.
* `location` - (Optional) The location of the source code from git or s3.
* `report_build_status` - (Optional) Set to `true` to report the status of a build's start and finish to your source provider. This option is only valid when your source provider is GitHub.
* `report_build_status` - (Optional) Set to `true` to report the status of a build's start and finish to your source provider. This option is only valid when your source provider is `GITHUB`, `BITBUCKET`, or `GITHUB_ENTERPRISE`.

## Attributes Reference

Expand Down