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

What would be the permissions required for Github PAT for Azure Devops build to work? #238

Closed
shwetanshu-cldcvr opened this issue Nov 27, 2020 · 2 comments

Comments

@shwetanshu-cldcvr
Copy link

I gave the following permissions to Github Account used in ADO along with admin access to Repos still I get the error :

Error: error creating resource Build Definition: Unable to configure a service on the selected GitHub repository. This is likely caused by not having the necessary permission to manage hooks for the selected repository.

admin:repo_hook:Full control of repository hooks
write:repo_hook:Write repository hooks
read:repo_hook:Read repository hooks
admin:org_hook:Full control of organization hooks
read:user
user:email

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Nov 30, 2020

@shwetanshu-cldcvr Your permission configuration should be enough to create the build definitions. Can you check that if the GitHub personal access token used in the service connection and the repository in build definition point to the same GitHub organization.

My test configuration:
image

resource "azuredevops_project" "project" {
  name       = "Sample Project"
  visibility         = "private"
  version_control    = "Git"
  work_item_template = "Agile"
}



resource "azuredevops_serviceendpoint_github" "serviceendpoint_gh_1" {
  project_id = azuredevops_project.project.id
  service_endpoint_name = "Sample GithHub Personal Access Token"

  auth_personal {
    personal_access_token = "xxxxxxxxxxx"
  }
}

resource "azuredevops_resource_authorization" "auth" {
  project_id = azuredevops_project.project.id
  resource_id = azuredevops_serviceendpoint_github.serviceendpoint_gh_1.id
  authorized = true
}

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

  ci_trigger {
    use_yaml = true
  }

  repository {
    repo_type = "GitHub"
    repo_id = "orgName/repoName"
    service_connection_id = azuredevops_serviceendpoint_github.serviceendpoint_gh_1.id
    yml_path = "azure-pipelines.yml"
  }

  variable {
    name = "PipelineVariable"
    value = "Go Microsoft!"
  }

  variable {
    name = "PipelineSecret"
    secret_value = "ZGV2cw"
    is_secret = true
  }
}

@shwetanshu-cldcvr
Copy link
Author

Ahh, I was using data.github_repository.main.id as input to repo name and that was causing it to fail. Used directly with repo name and it worked.

Thanks a lot for pointing in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants