From a826aba4a3af5c3b09a09fcf106b2d16486d7462 Mon Sep 17 00:00:00 2001 From: smmaster Date: Fri, 21 Feb 2020 14:51:42 +0100 Subject: [PATCH 1/4] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 115 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..b6c26032a --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,115 @@ +# Python to Linux Web App on Azure +# Build your Python project and deploy it to Azure as a Linux Web App. +# Change python version to one thats appropriate for your application. +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: 'b1cb01dc-3427-4d77-8940-c0a222d9787f' + + # Web app name + webAppName: 'Appjdjdghhdhdhd' + ProdwebAppName: 'app00101-prod' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'Appjdjdghhdhdhd' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + # Python version: 3.7 + pythonVersion: '3.7' + +stages: +- stage: Build + displayName: Build stage + jobs: + - job: BuildJob + pool: + vmImage: $(vmImageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python $(pythonVersion)' + + - script: | + python -m venv antenv + source antenv/bin/activate + python -m pip install --upgrade pip + pip install setup + pip install -r requirements.txt + workingDirectory: $(projectRoot) + displayName: "Install requirements" + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(projectRoot)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + displayName: 'Upload package' + artifact: drop + +- stage: Deploy + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : Appjdjdghhdhdhd' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip + + +- stage: Deploy to prod + displayName: 'Deploy Web App' + dependsOn: Build + condition: succeeded() + jobs: + - deployment: DeploymentJob + pool: + vmImage: $(vmImageName) + environment: $(environmentName) + strategy: + runOnce: + deploy: + steps: + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(pythonVersion)' + displayName: 'Use Python version' + + - task: AzureWebApp@1 + displayName: 'Deploy Azure Web App : Appjdjdghhdhdhd' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(ProdwebAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From 422dcd858587ebbe56214da8c5f2c611f608ccf2 Mon Sep 17 00:00:00 2001 From: smmaster Date: Fri, 21 Feb 2020 14:52:46 +0100 Subject: [PATCH 2/4] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b6c26032a..4b73e4642 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -88,7 +88,7 @@ stages: package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip -- stage: Deploy to prod +- stage: Deploy2Prod displayName: 'Deploy Web App' dependsOn: Build condition: succeeded() From 4a4b506d85e9305dbc71aad70b8f53e06ca872f2 Mon Sep 17 00:00:00 2001 From: smmaster Date: Fri, 21 Feb 2020 15:03:21 +0100 Subject: [PATCH 3/4] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4b73e4642..65167c1ae 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,8 @@ variables: vmImageName: 'ubuntu-latest' # Environment name - environmentName: 'Appjdjdghhdhdhd' + environmentName: 'Dev' + ProdenvironmentName: 'Prod' # Project root folder. Point to the folder containing manage.py file. projectRoot: $(System.DefaultWorkingDirectory) @@ -96,7 +97,7 @@ stages: - deployment: DeploymentJob pool: vmImage: $(vmImageName) - environment: $(environmentName) + environment: $(ProdenvironmentName) strategy: runOnce: deploy: From a0e0abdd82b576e4319978a8614f563aed9be0bd Mon Sep 17 00:00:00 2001 From: smmaster Date: Fri, 21 Feb 2020 15:03:50 +0100 Subject: [PATCH 4/4] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 65167c1ae..704a33084 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -62,7 +62,7 @@ stages: displayName: 'Upload package' artifact: drop -- stage: Deploy +- stage: DeployDev displayName: 'Deploy Web App' dependsOn: Build condition: succeeded() @@ -91,7 +91,7 @@ stages: - stage: Deploy2Prod displayName: 'Deploy Web App' - dependsOn: Build + dependsOn: DeployDev condition: succeeded() jobs: - deployment: DeploymentJob