« Azure pipeline » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
(→YAML) |
(→YAML) |
||
Ligne 27 : | Ligne 27 : | ||
= YAML = | = YAML = | ||
* [https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml Specify jobs in your pipeline] | * [https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml Specify jobs in your pipeline] | ||
* [https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates Template types & usage] | * [https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates Template types & usage] | ||
Ligne 71 : | Ligne 70 : | ||
deploy: | deploy: | ||
steps: ${{ parameters.myStepList }} | steps: ${{ parameters.myStepList }} | ||
</kode> | |||
== [https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#environment YAML schema reference] == | |||
=== [https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#job] === | |||
<kode lang='yaml'> | |||
jobs: | |||
- job: job_name # (A-Z, a-z, 0-9, and underscore) | |||
displayName: 'Job name' # friendly name to display in the UI | |||
dependsOn: string | [ string ] | |||
condition: string | |||
strategy: | |||
parallel: # parallel strategy; see the following "Parallel" topic | |||
matrix: # matrix strategy; see the following "Matrix" topic | |||
maxParallel: number # maximum number of matrix jobs to run simultaneously | |||
continueOnError: boolean # 'true' if future jobs should run even if this job fails; defaults to 'false' | |||
pool: pool # see the following "Pool" schema | |||
workspace: | |||
clean: outputs | resources | all # what to clean up before the job runs | |||
container: containerReference # container to run this job inside of | |||
timeoutInMinutes: number # how long to run the job before automatically cancelling | |||
cancelTimeoutInMinutes: number # how much time to give 'run always even if cancelled tasks' before killing them | |||
variables: # several syntaxes, see specific section | |||
steps: [ script | bash | pwsh | powershell | checkout | task | templateReference ] | |||
services: { string: string | container } # container resources to run as a service container | |||
</kode> | </kode> | ||
Version du 12 août 2020 à 13:59
Links
- Azure Pipelines documentation
- Key concepts for new Azure Pipelines users
- Use approvals and gates to control your deployment
Definitions
Term | Definition |
---|---|
Artifact | item from a git repository or a build pipeline |
Stages | steps to deploy and validate a software a stage contains jobs |
Job | subparts of a stage, contains tasks to execute listed as steps a job runs on a agent or can be manually ran |
Tasks / Steps | subparts of a job, those are the concreate action to execute |
Release pipeline definition | steps to execute to get the artefacts, install and validate the software template to run a release |
Release agent | the one who execute the tasks defined in the release pipeline definition it is the same agent as the one used for the build |
Release variables
YAML
- Specify jobs in your pipeline
- Template types & usage
- Approvals in environments with multi-stage YAML pipelines
Create a new pipeline
From an existing YAML file
Exemple
# do not trigger the pipeline on events trigger: none parameters: - name: myStepList type: stepList default: - bash: echo "We are on $(MyVar)" # If you have a single stage, you can omit the stages keyword and directly specify the jobs keyword stages: - stage: CI displayName: CI stage # remove implicite depency on the previous stage, the stages will run in parallel dependsOn: [] jobs: - job: ci_job pool: MyPool # If you have a single stage and a single job, you can omit the stages and jobs keywords and directly specify the steps keyword steps: - powershell: Write-Host "We are on CI" enabled: false # disable the task - stage: PROD displayName: PROD stage dependsOn: [] jobs: # use deployment job with environment and strategy to use the approval mechanism - deployment: prod_job environment: PROD strategy: runOnce: deploy: steps: ${{ parameters.myStepList }} |
YAML schema reference
[1]
jobs: - job: job_name # (A-Z, a-z, 0-9, and underscore) displayName: 'Job name' # friendly name to display in the UI dependsOn: string | [ string ] condition: string strategy: parallel: # parallel strategy; see the following "Parallel" topic matrix: # matrix strategy; see the following "Matrix" topic maxParallel: number # maximum number of matrix jobs to run simultaneously continueOnError: boolean # 'true' if future jobs should run even if this job fails; defaults to 'false' pool: pool # see the following "Pool" schema workspace: clean: outputs | resources | all # what to clean up before the job runs container: containerReference # container to run this job inside of timeoutInMinutes: number # how long to run the job before automatically cancelling cancelTimeoutInMinutes: number # how much time to give 'run always even if cancelled tasks' before killing them variables: # several syntaxes, see specific section steps: [ script | bash | pwsh | powershell | checkout | task | templateReference ] services: { string: string | container } # container resources to run as a service container |
PowerShell task
- task: PowerShell@2 displayName: 'PowerShell Script' inputs: targetType: filePath filePath: 'MyScript.ps1' arguments: '-Arg1 "Arg1"' - task: PowerShell@2 displayName: 'PowerShell Script' inputs: targetType: inline script: | 'cmd1' 'cmd2' - powershell: 'cmd' # 4 blank characters before the command - powershell: | 'cmd1' 'cmd2' # pwsh runs PowerShell Core, which must be installed on the agent or container. - pwsh: 'cmd' |
Variables
# scope: root, stage, job variables: variable_name: 'value' |
Runtime parameters
Ces paramètres sont sélectionnable à chaque lancement de la pipeline.
parameters: - name: my_parameter displayName: My parameter type: string default: Value1 values: - Value1 - Value2 |
Repositories
By default current pipeline repo is checked out. |
resources: repositories: - repository: RepoId # A-Z, a-z, 0-9, and underscore name: ProjectName/RepoName # repository name (format depends on `type`) type: git ref: master steps: - checkout: self # checkout in C:\agent\_work\1\s\CurrentRepoId - checkout: RepoId # checkout in C:\agent\_work\1\s\RepoId |
|
Condition
stages: - stage: Stage1 condition: eq(variables.Var1, 'Value1') jobs: - job: steps: - powershell: 'cmd' condition: eq('${{ parameters.Param1 }}', 'Value1') |
Steps of a release
- Build the software with a pipeline
- validate product quality (unit tests, SonarCloud)
- Deploy the software
- validate runtime stability (compare telemetry with previous version)
- Release the feature
- validate feature usage