https://github.com/avinor/azure-pipelines-templates
Azure Pipeline templates for building various projects with Azure Devops Pipelines
https://github.com/avinor/azure-pipelines-templates
azure azure-pipelines devops pipeline terraform
Last synced: 5 months ago
JSON representation
Azure Pipeline templates for building various projects with Azure Devops Pipelines
- Host: GitHub
- URL: https://github.com/avinor/azure-pipelines-templates
- Owner: avinor
- License: apache-2.0
- Archived: true
- Created: 2019-05-08T06:38:48.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-05T08:06:46.000Z (over 5 years ago)
- Last Synced: 2024-08-09T02:19:14.854Z (9 months ago)
- Topics: azure, azure-pipelines, devops, pipeline, terraform
- Homepage:
- Size: 52.7 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - avinor/azure-pipelines-templates - Azure Pipeline templates for building various projects with Azure Devops Pipelines (Others)
README
# Azure Pipeline templates
This is a collection of various templates used in build, test and deploy of various code repositories. Depending on how code should be built or deployed different stages, jobs or steps can be included from project.
## Setup
To use the templates a service connection towards Github has to be created. In `azure-pipelines.yaml` add a reference to this repository.
```yaml
resources:
repositories:
- repository: templates
type: github
name: avinor/azure-pipelines-templates
endpoint: endpoint-name
```To target a specific version of the pipelines add for instance `ref: refs/tags/v1.0`.
## Templates
In most cases only the stages templates have to be included from `azure-pipelines.yaml` file. It is also possible to use the jobs and steps directly, but stages will define most common scenarios.
### terraform.yaml
`stages/terraform.yaml` defines a template to plan and apply terraform templates using terragrunt. It takes a list of paths that are configured as jobs in Azure Pipeline. In each path it will first run `terragrunt plan-all` and then `terragrunt apply-all`.
```yaml
resources:
repositories:
- repository: templates
type: github
name: avinor/azure-pipelines-templates
endpoint: endpoint-namestages:
- template: stages/terraform.yaml@templates
parameters:
azureSubscription: 'subscription-name'
environment: env-name
sasToken: sas-token
paths:
- name: WestEurope
displayName: West Europe
path: path-for-resources/westeurope
```Stage template takes 4 input parameters:
| Parameter | Description
|-----------|------------
| `azureSubscription` | Name of the service connection to use for the AzureCLI task. Need to have permissions to do the deployment
| `environment` | Name of environment to deploy to. Test, stage, prod etc
| `sasToken` | SAS Token to access storage account for shared state. This is a secret
| `paths` | A list of jobs to add. Each taking `name`, `displayName` and `path`. First 2 defining job properties and last the path in repository where resources to deploy exist.### terraform-modules.yaml
Terraform modules runs some simple validations on a terraform module. It will look for all examples folders in the repository and run validation on examples:
```bash
terraform init -backend=false examples/...
terraform validate examples/...
```It will always set backend to false to make sure that modules that define terraform configuration does not fail.
```yaml
resources:
repositories:
- repository: templates
type: github
name: avinor/azure-pipelines-templates
endpoint: endpoint-namestages:
- template: stages/terraform-modules.yaml@templates
```