GPT Pull Request review Task for Azure PipelinesThe GPT Pull Request Review Task for Azure Pipelines is designed to use the GPT model from OpenAI to review Pull Requests and provide feedback as comments in the Pull Request. SetupBefore using this task, ensure that the build service has permissions to contribute to Pull Requests in your repository, and allow the task to access the system token. Give permission to the build service agentTo allow the build service agent to contribute to pull requests, navigate to Project Settings > Repositories, select your repository, and grant "Project Collection Build Service" permissions for "Contribute," and "Contribute to Pull Requests." Save your changes to apply the permissions. Yaml pipelinesAdd a checkout section with persistCredentials set to true.
Azure Open AI serviceIf you choose to use the Azure Open AI service, you must fill in the endpoint and API key of Azure OpenAI. The format of the endpoint is as follows: https://{XXXXXXXX}.openai.azure.com/openai/deployments/{MODEL_NAME}/chat/completions?api-version={API_VERSION} To create openai resource and model deployment through devops pipeline arm template and sample .yml file given in (https://dev.azure.com/demoacct1982/Azure%20AI%20Extension%20for%20PR/_git/azure-pipeline-gpt-pr-review-main?path=/Infra&version=GBmain) in this location you can use this or else directly you can create resource and model in azure portal. OpenAI ModelsIn case you don't use Azure Open AI Service, you can choose which model to use, the supported models are "gpt-4", "gpt-3.5-turbo" and "gpt-3.5-turbo-16k". if no model is selected the "gpt-3.5-turbo" is used. How to use itInstall the extensionTo use the GPT Pull Request Review Task, first install the extension in your Azure DevOps organization. Click on the "Get it free" button and follow the prompts to install it. You may need to authorize the extension to access your Azure DevOps account. Add the task to the build pipelineAfter installing the extension, add the task to your build pipeline. Go to your build pipeline, click on the "+" icon to add a new task, and search for "Review PullRequest by GPT". Select it and add it to your pipeline. Configure the taskOnce you have added the task to your pipeline, configure it. In the task configuration, provide your API key for OpenAI API. you will get key in azure portal under your openai resource. endpoint OpenApi Endpoint : for that you have to use https://{XXXXXXXX}.openai.azure.com/openai/deployments/{MODEL_NAME}/chat/completions?api-version={API_VERSION} this format (eg. (Azure OpenApi Endpoint)/openai/deployments/{MODEL_NAME}/chat/completions?api-version=2024-02-15-preview) (MODEL_NAME) Then run pipeline once and then add build validation on main branch for that go to repository settings under policies add build validation on that branch and select pipeline under which you have added GPT task. after this whenever pull request created to merge with main branch on which you have added build validation GPT task will runs and add comments on that pull request. Review Pull RequestsWhen the build is triggered from a Pull Request, the task will review it. If there is feedback on the changed code, the task will add comments to the Pull Request. If the build is triggered manually, the task will be skipped. Compatible with Linux Build AgentsThe tasks can execute on all supported build agent operating systems including Linux and MacOS. |