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

Add Support for GitHub enterprise as a build definition repository type #97

Merged
merged 3 commits into from
Jul 24, 2020
Merged

Add Support for GitHub enterprise as a build definition repository type #97

merged 3 commits into from
Jul 24, 2020

Conversation

shubydo
Copy link
Contributor

@shubydo shubydo commented Jul 20, 2020

All Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • I ran lint checks locally prior to submission.
  • Have you checked to ensure there aren't other open PRs for the same update/change?

What about the current behavior has changed?

Add Support for GitHub enterprise as a build definition repository type.

Under the repository block in the azuredevops_build_definition resource, you can now specify GitHubEnterprise as the repo_type and specify the Github Enterprise URL using the github_enterprise_url .

Example:

resource "azuredevops_build_definition" "sample_dotnetcore_app_release" {
  project_id = azuredevops_project.project.id
  name       = "Sample Build Definition"
  path       = "\\ExampleFolder"

  ci_trigger {
    use_yaml = true
  }

  repository {
    repo_type             = "GitHubEnterprise"
    repo_id               = "<GitHub Org>/<Repo Name>"
    github_enterprise_url = "https://github.51.alpany.com"
    branch_name           = "master"
    yml_path              = "azure-pipelines.yml"
    service_connection_id = "..."
  }

}

Issue Number: #35

Does this introduce a change to go.mod, go.sum or vendor/?

  • Yes
  • No

Does this introduce a breaking change?

  • Yes
  • No

Any relevant logs, error output, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Other information

@shubydo shubydo changed the title Feature/ghe build definition support Add Support for GitHub enterprise as a build definition repository type. Jul 20, 2020
@shubydo shubydo marked this pull request as ready for review July 20, 2020 19:44
@shubydo shubydo changed the title Add Support for GitHub enterprise as a build definition repository type. Add Support for GitHub enterprise as a build definition repository type Jul 21, 2020
@xuzhang3
Copy link
Collaborator

Hi @shubydo , I'm afraid this new feature might not working if repo_type is GitHubEnterprise because ADO provider doesn't support create GitHub enterprise service connection yet.
During build definition creation, service will use the service connection connect to GitHub enterprise and fetch the repository meta data. If service connection doesn't exist, the creation will fail. One possible way is using an existed project and GitHub enterprise service connection.

@shubydo
Copy link
Contributor Author

shubydo commented Jul 22, 2020

Hi @shubydo , I'm afraid this new feature might not working if repo_type is GitHubEnterprise because ADO provider doesn't support create GitHub enterprise service connection yet.
During build definition creation, service will use the service connection connect to GitHub enterprise and fetch the repository meta data. If service connection doesn't exist, the creation will fail. One possible way is using an existed project and GitHub enterprise service connection.

@xuzhang3 Yes, currently the ADO provider doesn't support creating GitHub enterprise service connections, but I was able to use the ID of an existing GitHub enterprise service connection (created through the console/UI) when creating the build definition.

Also, there is a check to validate that a service connection ID is used when repo_type is GitHubEnterprise here.

@@ -831,6 +848,12 @@ func expandBuildDefinition(d *schema.ResourceData) (*build.BuildDefinition, stri
repoURL = fmt.Sprintf("https://bitbucket.org/%s.git", repoID)
repoAPIURL = fmt.Sprintf("https://api.bitbucket.org/2.0/repositories/%s", repoID)
}
if strings.EqualFold(string(repoType), string(model.RepoTypeValues.GitHubEnterprise)) {
githubEnterpriseURL := repository["github_enterprise_url"].(string)
fmt.Println("githubEnterpriseURL: ", githubEnterpriseURL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Println should removed or replace with log.Printf

@@ -11,6 +11,7 @@ Manages a Build Definition within Azure DevOps.

## Example Usage

### Tfs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does Tfs mean ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Team Foundation Server + Git. It's an example when repo_type is TfsGit

@@ -98,9 +122,10 @@ The following arguments are supported:

- `branch_name` - (Optional) The branch name for which builds are triggered. Defaults to `master`.
- `repo_id` - (Required) The id of the repository. For `TfsGit` repos, this is simply the ID of the repository. For `Github` repos, this will take the form of `<GitHub Org>/<Repo Name>`. For `Bitbucket` repos, this will take the form of `<Workspace ID>/<Repo Name>`.
- `repo_type` - (Optional) The repository type. Valid values: `GitHub` or `TfsGit` or `Bitbucket`. Defaults to `Github`.
- `service_connection_id` - (Optional) The service connection ID. Used if the `repo_type` is `GitHub`.
- `repo_type` - (Optional) The repository type. Valid values: `GitHub` or `TfsGit` or `Bitbucket` or `GitHub Enterprise`. Defaults to `Github`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document should point out if repo_type is `GitHubEnterprise`` , must use existing project and GitHub enterprise service connection.

Copy link
Collaborator

@xuzhang3 xuzhang3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubydo Thanks for contribution and I left some comments on what you might need to change.

@shubydo
Copy link
Contributor Author

shubydo commented Jul 23, 2020

@shubydo Thanks for contribution and I left some comments on what you might need to change.

Made the updates. Please let me know if there is anything else.

@xuzhang3 xuzhang3 merged commit 66b381f into microsoft:master Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants