From dbffa7243a3ee61b056c326eeee70bbeb37adbbd Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:01:52 +0300 Subject: [PATCH 01/40] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..5d647dc65 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,86 @@ +# 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: +- main + +variables: + # Azure Resource Manager connection created during pipeline creation + azureServiceConnectionId: 'b69a0940-36ac-4582-9575-7ccd036b954e' + + # Web app name + webAppName: 'webapp1312' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + + # Environment name + environmentName: 'webapp1312' + + # Project root folder. Point to the folder containing manage.py file. + projectRoot: $(System.DefaultWorkingDirectory) + + pythonVersion: '3.11' + +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 : webapp1312' + inputs: + azureSubscription: $(azureServiceConnectionId) + appName: $(webAppName) + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file From 9ac3b702abcb4382a5f8b26d4a7aaa6287579b96 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:37:51 +0300 Subject: [PATCH 02/40] Update azure-pipelines.yml --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d647dc65..f02adc73e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ variables: azureServiceConnectionId: 'b69a0940-36ac-4582-9575-7ccd036b954e' # Web app name - webAppName: 'webapp1312' + webAppName: 'webapp1312new' # Agent VM image name vmImageName: 'ubuntu-latest' @@ -83,4 +83,4 @@ stages: inputs: azureSubscription: $(azureServiceConnectionId) appName: $(webAppName) - package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip \ No newline at end of file + package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip From b82a5a2340d0a557eee44507c7fbc8f333777840 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:46:27 +0300 Subject: [PATCH 03/40] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f02adc73e..be665b48b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ variables: azureServiceConnectionId: 'b69a0940-36ac-4582-9575-7ccd036b954e' # Web app name - webAppName: 'webapp1312new' + webAppName: 'webapp1312' # Agent VM image name vmImageName: 'ubuntu-latest' From a07533da726a4d864a2a608147bbdfbf8daad476 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:00:53 +0300 Subject: [PATCH 04/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index be665b48b..48cad9961 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -58,6 +58,32 @@ stages: - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip displayName: 'Upload package' artifact: drop +- stage: Versioning + dependsOn: Build + condition: succeeded() + jobs: + - job: TagAndVersion + pool: + vmImage: 'ubuntu-latest' + steps: + - checkout: self + persistCredentials: true + + - script: | + git config user.name "Azure DevOps" + git config user.email "buildagent@devops.com" + + git fetch --tags + + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + version=${latest_tag#v} + IFS='.' read -r major minor patch <<< "$version" + new_tag="v$major.$minor.$((patch + 1))" + echo "##vso[build.updatebuildnumber]$new_tag" + + git tag $new_tag + git push origin $new_tag + displayName: 'Version and Tag Source' - stage: Deploy displayName: 'Deploy Web App' From af05e7acdad0a528b8d7505803918bc6a5491c1f Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:36:45 +0300 Subject: [PATCH 05/40] 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 48cad9961..135917065 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -70,8 +70,8 @@ stages: persistCredentials: true - script: | - git config user.name "Azure DevOps" - git config user.email "buildagent@devops.com" + git config user.name "Radu Hasegan" + git config user.email "radu,hasegan80@gmail.com" git fetch --tags From 998ce96ab64923710e180ca701dcbcd1a60039f1 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:46:14 +0300 Subject: [PATCH 06/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 47 ++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 135917065..f8ce545ee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -58,33 +58,28 @@ stages: - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip displayName: 'Upload package' artifact: drop -- stage: Versioning - dependsOn: Build - condition: succeeded() +- stage: Release + displayName: 'Create Release with Tag' jobs: - - job: TagAndVersion - pool: - vmImage: 'ubuntu-latest' - steps: - - checkout: self - persistCredentials: true - - - script: | - git config user.name "Radu Hasegan" - git config user.email "radu,hasegan80@gmail.com" - - git fetch --tags - - latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) - version=${latest_tag#v} - IFS='.' read -r major minor patch <<< "$version" - new_tag="v$major.$minor.$((patch + 1))" - echo "##vso[build.updatebuildnumber]$new_tag" - - git tag $new_tag - git push origin $new_tag - displayName: 'Version and Tag Source' - + - job: ReleaseJob + displayName: 'Release Job' + pool: + vmImage: 'ubuntu-latest' + steps: + - checkout: self + + # Get the version (tag) from the version.txt file + - script: | + VERSION=$(cat version.txt) + echo "Using version: $VERSION" + git tag "$VERSION" + git push origin "$VERSION" + displayName: 'Create Git Tag' + + # Example Release Step: Deploy Application (or any other release tasks) + - script: | + echo "Deploying version $VERSION" + displayName: 'Deploy Application' - stage: Deploy displayName: 'Deploy Web App' dependsOn: Build From a2daffd084a29eb8b941cb91f024fc82b36e44b4 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:52:01 +0300 Subject: [PATCH 07/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f8ce545ee..332aea57b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -70,6 +70,7 @@ stages: # Get the version (tag) from the version.txt file - script: | + git rev-parse --short HEAD VERSION=$(cat version.txt) echo "Using version: $VERSION" git tag "$VERSION" From ca510e32f4ebd8397497a2574debdd25027fad93 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:44:36 +0300 Subject: [PATCH 08/40] Create version.txt --- version.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 version.txt diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..3eefcb9dd --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.0.0 From c84546ff6ca7dcd9e6e51ee287c3db139a72705e Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:08:36 +0300 Subject: [PATCH 09/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 332aea57b..d9a3971b2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,6 +24,13 @@ variables: pythonVersion: '3.11' +resources: + repositories: + - repository: flaskApp + type: github + name: RaduHasegan/python-sample-vscode-flask-tutorial + endpoint: github.com_RaduHasegan # replace with your service connection name + stages: - stage: Build displayName: Build stage From 30ceb42b0a88473f68438e998fd54b86122bc0b2 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:12:54 +0300 Subject: [PATCH 10/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d9a3971b2..966e43d75 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -73,7 +73,8 @@ stages: pool: vmImage: 'ubuntu-latest' steps: - - checkout: self + - checkout: flaskApp + persistCredentials: true # Get the version (tag) from the version.txt file - script: | From 73c31257fa053f8ddbb3b9b681c3546c3f962353 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:46:59 +0300 Subject: [PATCH 11/40] Update home.html --- hello_app/templates/home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello_app/templates/home.html b/hello_app/templates/home.html index 95609fecd..fc0c5d2bc 100644 --- a/hello_app/templates/home.html +++ b/hello_app/templates/home.html @@ -3,5 +3,5 @@ Home {% endblock %} {% block content %} -
Home page for the Visual Studio Code Flask tutorial.
+Radu Home page for the Visual Studio Code Flask tutorial.
{% endblock %} From ec24b27b1efa4d37e377e15982c64a4fd9638e9c Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:07:27 +0300 Subject: [PATCH 12/40] Update home.html --- hello_app/templates/home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello_app/templates/home.html b/hello_app/templates/home.html index fc0c5d2bc..144a13fd7 100644 --- a/hello_app/templates/home.html +++ b/hello_app/templates/home.html @@ -3,5 +3,5 @@ Home {% endblock %} {% block content %} -Radu Home page for the Visual Studio Code Flask tutorial.
+Radunew Home page for the Visual Studio Code Flask tutorial.
{% endblock %} From e5f23797568f7a41be81542a1b4fd388ecfd4f30 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:36:49 +0300 Subject: [PATCH 13/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 966e43d75..a818dd865 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ resources: - repository: flaskApp type: github name: RaduHasegan/python-sample-vscode-flask-tutorial - endpoint: github.com_RaduHasegan # replace with your service connection name + endpoint: github.com_RaduHasegan stages: - stage: Build @@ -77,15 +77,14 @@ stages: persistCredentials: true # Get the version (tag) from the version.txt file - - script: | - git rev-parse --short HEAD - VERSION=$(cat version.txt) - echo "Using version: $VERSION" - git tag "$VERSION" - git push origin "$VERSION" - displayName: 'Create Git Tag' - - # Example Release Step: Deploy Application (or any other release tasks) + - bash: | + version=$(cat version.txt) + IFS='.' read -ra parts <<< "$version" + patch=$((parts[2] + 1)) + new_version="${parts[0]}.${parts[1]}.$patch" + echo $new_version > version.txt + echo "##vso[build.updatebuildnumber]$new_version" + displayName: 'Increment patch version' - script: | echo "Deploying version $VERSION" displayName: 'Deploy Application' From c7a90fc671adc6fd7db1555075a1de8acb652758 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:45:26 +0300 Subject: [PATCH 14/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a818dd865..d86794e42 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -85,9 +85,14 @@ stages: echo $new_version > version.txt echo "##vso[build.updatebuildnumber]$new_version" displayName: 'Increment patch version' - - script: | - echo "Deploying version $VERSION" - displayName: 'Deploy Application' + - bash: | + git config user.name "Radu Hasegan" + git config user.email "radu.hasegan80@gmail.com" + git add version.txt + git commit -m "Increment version to $(cat version.txt)" + git push + displayName: 'Commit new version' + condition: succeeded() - stage: Deploy displayName: 'Deploy Web App' dependsOn: Build From f601b2bb8c4db3065199f0befdc86183a9d8c713 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:50:24 +0300 Subject: [PATCH 15/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d86794e42..dbb150b4a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -86,6 +86,7 @@ stages: echo "##vso[build.updatebuildnumber]$new_version" displayName: 'Increment patch version' - bash: | + git checkout main git config user.name "Radu Hasegan" git config user.email "radu.hasegan80@gmail.com" git add version.txt From aecc0a200741b699b065cd62074ab68b111242eb Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:52:45 +0300 Subject: [PATCH 16/40] 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 dbb150b4a..a5cd4ac82 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,7 +91,7 @@ stages: git config user.email "radu.hasegan80@gmail.com" git add version.txt git commit -m "Increment version to $(cat version.txt)" - git push + git push origin main displayName: 'Commit new version' condition: succeeded() - stage: Deploy From 22014a4aa5cadb04fce4a92d4c2c5ff1293c7508 Mon Sep 17 00:00:00 2001 From: RaduHasegan <60115015+RaduHasegan@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:56:17 +0300 Subject: [PATCH 17/40] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5cd4ac82..05b0694de 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -86,6 +86,7 @@ stages: echo "##vso[build.updatebuildnumber]$new_version" displayName: 'Increment patch version' - bash: | + git fetch origin git checkout main git config user.name "Radu Hasegan" git config user.email "radu.hasegan80@gmail.com" @@ -93,7 +94,7 @@ stages: git commit -m "Increment version to $(cat version.txt)" git push origin main displayName: 'Commit new version' - condition: succeeded() + condition: succeeded() - stage: Deploy displayName: 'Deploy Web App' dependsOn: Build From 0188198a00b335e249bfff8b80e7353e84364e5a Mon Sep 17 00:00:00 2001 From: Radu HaseganRadunew Home page for the Visual Studio Code Flask tutorial.
+Radunew2 Home page for the Visual Studio Code Flask tutorial.
{% endblock %} From 96cfd9b5fe89519765a0744551e234c3849ec86b Mon Sep 17 00:00:00 2001 From: Radu Hasegan