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

Docs/quickstart for ado #3220

Merged
merged 20 commits into from
Feb 1, 2025
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c1b430e
Created `quickstart-for-ado.md`
that-ar-guy Jan 7, 2025
5cfb6ec
Updated `quickstart-for-ado.md`
that-ar-guy Jan 7, 2025
41fc60e
Merge branch 'Azure:main' into docs/quickstart-for-ado
that-ar-guy Jan 13, 2025
f339080
Rename `quickstart-for-ado.md` to `test-bicep-with-azure-pipelines.md`
that-ar-guy Jan 13, 2025
adcdd30
Add `test-bicep-with-azure-pipelines` to `mkdocs.yml`
that-ar-guy Jan 13, 2025
b6d39ed
Update `CHANGELOG-v1.md`
that-ar-guy Jan 13, 2025
b6cd711
Update test-bicep-with-azure-pipelines.md
that-ar-guy Jan 13, 2025
1540d7a
Add sample Bicep deployment to quickstart guide
that-ar-guy Jan 13, 2025
47ea576
Update pipeline steps with extension and PowerShell syntax using Asse…
that-ar-guy Jan 13, 2025
e225f13
Merge branch 'main' into docs/quickstart-for-ado
that-ar-guy Jan 14, 2025
aca4d24
Changed `JUnit` to `Nunit3`
that-ar-guy Jan 15, 2025
29f5f72
Update `ps-rule.yaml`
that-ar-guy Jan 15, 2025
ce3aad3
Merge branch 'Azure:main' into docs/quickstart-for-ado
that-ar-guy Jan 18, 2025
40daeb1
`ps-rule.yaml` reverted
that-ar-guy Jan 18, 2025
9990f67
Updates
BernieWhite Jan 21, 2025
1dffec0
Merge branch 'main' into docs/quickstart-for-ado
BernieWhite Jan 21, 2025
d02968d
Merge branch 'main' into docs/quickstart-for-ado
BernieWhite Jan 21, 2025
3922e74
Merge branch 'main' into docs/quickstart-for-ado
BernieWhite Jan 30, 2025
1a4a1c2
Merge branch 'main' into docs/quickstart-for-ado
BernieWhite Feb 1, 2025
ab94fc4
Merge branch 'main' into docs/quickstart-for-ado
BernieWhite Feb 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions docs/quickstarts/quickstart-for-ado.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Quickstart: Use PSRule for Azure with Azure DevOps

This quickstart guide will help you set up PSRule for Azure in an Azure DevOps pipeline to validate Infrastructure as Code (IaC) templates, such as ARM or Bicep files. By the end, you will have a pipeline that installs and runs PSRule, validates IaC templates, and publishes validation results in Azure DevOps Test Reports.

## Prerequisites

1. **Azure DevOps account:** You need an Azure DevOps organization with an active project.
2. **IaC templates:** Ensure you have ARM or Bicep templates in your repository for validation.
3. **Agent pool:** An agent pool must be configured to execute pipelines. Use a self-hosted agent if needed.
4. **PowerShell Core:** Your build agent should have PowerShell Core installed (v7 or later).
5. **PSRule module:** The PSRule module will be installed during pipeline execution.

---

## Steps to Create the Pipeline

### Step 1: Add a Pipeline YAML File

Create a new file named `azure-pipeline.yml` in the root of your repository. This file defines the pipeline steps.

### Step 2: Define the Pipeline

Add the following content to your `azure-pipeline.yml` file:

```yaml
trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Install-Module -Name PSRule.Rules.Azure -Force -Scope CurrentUser
pwsh -Command "Invoke-PSRule -InputPath './templates'"

- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/psrule-results.xml'
```

### Step 3: Commit and Push

1. Commit your changes to the repository:
```bash
git add azure-pipeline.yml
git commit -m "Add Azure DevOps pipeline for PSRule validation"
git push origin main
```

2. The pipeline will automatically trigger and validate your templates.

---

## Reviewing Validation Results

1. Go to your Azure DevOps project.
2. Open the **Pipelines** section and view the pipeline run.
3. Look for validation output in the logs and **Test Results**.
4. Fix any reported issues in your IaC templates to pass validation.

---

For more information about PSRule for Azure, visit the [official documentation](https://azure.github.io/PSRule.Rules.Azure/).

Loading