diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..cbdfe7808 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,104 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python +trigger: + branches: + include: + - azure-pipelines-wens-test + +#paths: +#include: + #- awsAlarmIntegration/* + +pool: + vmImage: 'ubuntu-latest' + +#global variables: +variables: + isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')] # runtime expression + isMyBranch: $[eq(variables['Build.SourceBranch'], 'refs/heads/azure-pipelines-wens-test')] # runtime expression + +stages: +- stage: CI + displayName: 'Continuous Integration' + jobs: + - job: helloworld + timeoutInMinutes: 10 + steps: + - bash: echo "Hello world. I am in Stage CI" + + - job: Test + timeoutInMinutes: 10 + strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + + - script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + + - script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' + +- stage: TestfromMainBranch + dependsOn: CI + condition: and(succeeded(), eq(variables.isMain, true)) + displayName: 'Continuous Integration - Post Test' + jobs: + - job: PostTest + timeoutInMinutes: 10 + steps: + - bash: echo "Hello world. At Stage TestMainBranch" + +- stage: TestfromFeatureBranch + dependsOn: CI + condition: and(succeeded(), eq(variables.isMyBranch, true)) + displayName: 'Continuous Integration - Post Test' + jobs: + - job: PostTest + timeoutInMinutes: 10 + steps: + - script: echo $(Build.SourceBranchName) + +- stage: TestArtifacts + dependsOn: TestfromFeatureBranch + condition: succeeded() + jobs: + - job: main + steps: + - script: echo "##vso[task.setvariable variable=FOO;isOutput=true]Bar" + displayName: Set output variables + name: myEnv + - job: variables_handler + dependsOn: main + variables: + FOO: $[ dependencies.main.outputs['myEnv.FOO'] ] + steps: + - task: CmdLine@2 + displayName: Create artifact from variables + inputs: + script: | + echo "##vso[task.setvariable variable=FOO;]$(FOO)" > $(Build.ArtifactStagingDirectory)/pipeline.env + - task: PublishBuildArtifacts@1 + displayName: publish variables + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'variables' + publishLocation: 'Container' \ No newline at end of file