|
7 | 7 | name: '<value>' |
8 | 8 |
|
9 | 9 | variables: |
10 | | -- group: 'Claude-Code' |
| 10 | +- group: 'PullRequestAgentSecrets' # Variable group containing secrets like ANTHROPIC_API_KEY |
11 | 11 |
|
12 | | -steps: |
13 | | -- task: Docker@2 |
14 | | - displayName: 'Run Pull Request Review' |
15 | | - inputs: |
16 | | - containerRegistry: $(DOCKER_SERVICECONNECTION_NAME) |
17 | | - command: 'run' |
18 | | - arguments: >- |
19 | | - --name pr-agent-container |
20 | | - -e ANTHROPIC_API_KEY=$(ANTHROPIC_API_KEY) |
21 | | - -v $(Build.SourcesDirectory):/sources |
22 | | - -v $(Build.ArtifactStagingDirectory)/output:/output |
23 | | - $(ACR_NAME).azurecr.io/ado/pullrequestagent:latest |
24 | | - --ado-token $(System.AccessToken) |
25 | | - --pull-request-id $(System.PullRequest.PullRequestId) |
26 | | - --organization-name $(ADO_ORGANIZATION_NAME) |
27 | | - --project-name "$(System.TeamProject)" |
28 | | - --repository-name "$(Build.Repository.Name)" |
29 | | - --model $(MODEL_NAME) |
30 | | - --sources-directory /sources |
31 | | - --output-directory /output |
32 | | - env: |
33 | | - SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
| 12 | +stages: |
| 13 | + - stage: Build |
| 14 | + displayName: 'Run Pull Request Code Review Agent' |
| 15 | + jobs: |
| 16 | + - job: PullRequestReview |
| 17 | + displayName: 'Run Pull Request Code Review Agent' |
| 18 | + steps: |
| 19 | + - task: Docker@2 |
| 20 | + displayName: 'Run Pull Request Review' |
| 21 | + inputs: |
| 22 | + containerRegistry: $(DOCKER_SERVICECONNECTION_NAME) |
| 23 | + command: 'run' |
| 24 | + arguments: >- |
| 25 | + --name pr-agent-container |
| 26 | + -e ANTHROPIC_API_KEY=$(ANTHROPIC_API_KEY) |
| 27 | + -v $(Build.SourcesDirectory):/sources |
| 28 | + -v $(Build.ArtifactStagingDirectory)/output:/output |
| 29 | + $(ACR_NAME).azurecr.io/ado/pullrequestagent:latest |
| 30 | + --ado-token $(System.AccessToken) |
| 31 | + --pull-request-id $(System.PullRequest.PullRequestId) |
| 32 | + --organization-name $(ADO_ORGANIZATION_NAME) |
| 33 | + --project-name "$(System.TeamProject)" |
| 34 | + --repository-name "$(Build.Repository.Name)" |
| 35 | + --model $(MODEL_NAME) |
| 36 | + --sources-directory /sources |
| 37 | + --output-directory /output |
| 38 | + env: |
| 39 | + SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
34 | 40 |
|
35 | | -- task: PublishPipelineArtifact@1 |
36 | | - displayName: 'Publish review artifact' |
37 | | - inputs: |
38 | | - targetPath: '$(Build.ArtifactStagingDirectory)/output' |
39 | | - artifact: 'PullRequestReview' |
| 41 | + - task: PublishPipelineArtifact@1 |
| 42 | + displayName: 'Publish review artifact' |
| 43 | + inputs: |
| 44 | + targetPath: '$(Build.ArtifactStagingDirectory)/output' |
| 45 | + artifact: 'PullRequestReview' |
40 | 46 |
|
41 | | -- powershell: | |
42 | | - $summaryFile = "$(Build.ArtifactStagingDirectory)/output/review/code_review_summary.md" |
43 | | - if (Test-Path $summaryFile) { |
44 | | - $reviewFile = $summaryFile |
45 | | - } else { |
46 | | - $reviewFile = "$(Build.ArtifactStagingDirectory)/output/review/code_review.md" |
47 | | - } |
48 | | - $content = Get-Content -Path $reviewFile -Raw |
49 | | - $body = @{ |
50 | | - comments = @(@{ parentCommentId = 0; content = $content; commentType = 1 }) |
51 | | - status = 1 |
52 | | - } | ConvertTo-Json -Depth 3 |
53 | | - $uri = "$(System.CollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/threads?api-version=7.1" |
54 | | - $headers = @{ |
55 | | - Authorization = "Bearer $(System.AccessToken)" |
56 | | - 'Content-Type' = "application/json" |
57 | | - } |
58 | | - Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) -ContentType "application/json" |
59 | | - displayName: 'Post review as PR comment' |
60 | | - env: |
61 | | - SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
| 47 | + - powershell: | |
| 48 | + $summaryFile = "$(Build.ArtifactStagingDirectory)/output/review/code_review_summary.md" |
| 49 | + if (Test-Path $summaryFile) { |
| 50 | + $reviewFile = $summaryFile |
| 51 | + } else { |
| 52 | + $reviewFile = "$(Build.ArtifactStagingDirectory)/output/review/code_review.md" |
| 53 | + } |
| 54 | + $content = Get-Content -Path $reviewFile -Raw |
| 55 | + $body = @{ |
| 56 | + comments = @(@{ parentCommentId = 0; content = $content; commentType = 1 }) |
| 57 | + status = 1 |
| 58 | + } | ConvertTo-Json -Depth 3 |
| 59 | + $uri = "$(System.CollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/threads?api-version=7.1" |
| 60 | + $headers = @{ |
| 61 | + Authorization = "Bearer $(System.AccessToken)" |
| 62 | + 'Content-Type' = "application/json" |
| 63 | + } |
| 64 | + Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) -ContentType "application/json" |
| 65 | + displayName: 'Post review as PR comment' |
| 66 | + env: |
| 67 | + SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
0 commit comments