Skip to content

Commit 65b219e

Browse files
authored
docs: add azure pipelines CI integration (#4184)
* docs: add azure pipelines CI integration * docs: fix PR script * Update ci-setup.md
1 parent f185507 commit 65b219e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/guides/ci-setup.md

+41
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,47 @@ pipelines:
197197

198198
BitBucket limits git clone depth to 20 commits by default. You can change this behaviour by [changing the `clone` option](https://support.atlassian.com/bitbucket-cloud/docs/git-clone-behavior/).
199199

200+
## Azure Pipelines
201+
202+
```yml
203+
steps:
204+
- checkout: self
205+
fetchDepth: 0
206+
207+
- task: NodeTool@0
208+
inputs:
209+
versionSpec: '20.x'
210+
checkLatest: true
211+
212+
- script: |
213+
git --version
214+
node --version
215+
npm --version
216+
npx commitlint --version
217+
displayName: Print versions
218+
219+
- script: |
220+
npm install conventional-changelog-conventionalcommits
221+
npm install commitlint@latest
222+
displayName: Install commitlint
223+
224+
- script: npx commitlint --last --verbose
225+
condition: ne(variables['Build.Reason'], 'PullRequest')
226+
displayName: Validate current commit (last commit) with commitlint
227+
228+
- script: |
229+
echo "Accessing Azure DevOps API..."
230+
231+
response=$(curl -s -X GET -H "Cache-Control: no-cache" -H "Authorization: Bearer $(System.AccessToken)" $(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullRequests/$(System.PullRequest.PullRequestId)/commits?api-version=6.0)
232+
numberOfCommits=$(echo "$response" | jq -r '.count')
233+
234+
echo "$numberOfCommits commits to check"
235+
236+
npx commitlint --from $(System.PullRequest.SourceCommitId)~${numberOfCommits} --to $(System.PullRequest.SourceCommitId) --verbose
237+
condition: eq(variables['Build.Reason'], 'PullRequest')
238+
displayName: Validate PR commits with commitlint
239+
```
240+
200241
### 3rd party integrations
201242

202243
#### [Codemagic](https://codemagic.io/)

0 commit comments

Comments
 (0)