I’ve tried to do a pipeline with Python, but I got these errors. Anyone can help me? I am trying to do a Pipeline (CI/CD) for a web app in Python, which needs the: -Web App Server,-Database,-SonarQube. I created the database separately and put the connection information in my code, but I know it’s not the best way to do it. I really appreciate any help you can provide. Follow you can see my Pipeline.yaml and the error that I got.
Here you can see my pipeline:
# # Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change the python version to one that is 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: '*****************************'
# Agent VM image name
vmImageName: ubuntu-latest
# Environment name
environmentName: StudentWebappDev
# Project root folder. Point to the folder containing manage.py file.
projectRoot: C:codesStudentWebApp
# Python version: 3.7
pythonVersion: 3.7
stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildJob
pool:
vmImage: ubuntu-latest
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 freeze > requirements.txt
pip install -r requirements.txt
workingDirectory: $(System.DefaultWorkingDirectory)
displayName: "Install requirements"
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: $(System.DefaultWorkingDirectory)
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
# - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
# displayName: 'Upload package'
# artifact: drop
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop
publishLocation: 'Container'
- task: DownloadBuildArtifacts@0
inputs:
artifactName: drop
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: AzureWebApp@1
inputs:
package: $(System.DefaultWorkingDirectory)/**/*.zip
azureSubscription: 65e5170f-cbf2-4dc7-99a8-533049eea21d
appName: AppServiceStudentWeb
- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: ubuntu-latest
environment: StudentWebappDev
strategy:
runOnce:
deploy:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python version'`
2
Answers
I fixed this issue but I don't know why my website Python code with flask doesn't work. The Pipeline (azuredevops) running without error but when I try to access the link there is an application error. I will post my code, my yaml and the error. If somebody can help me, I would appreciate it. Thanks in advance
After running, I got this screen: image of error received
LOGS: https://pastebin.com/uUfWUL1m
Any help would be appreciated as I'm tired of trying to solve this problem alone and I can't, thank you very much.
I copied your yaml, confirm Build stage part is working. Task
AzureWebApp@1
is version 1.x(suggest to addappType
as it’s required).Check your error screenshot, suppose the
Azure App service deploy
task(version 4.229.0) should exist in your Deploy stage, but i cannot find it in your yaml.Different stages will execute on different agents(machines). If
drop.zip
is created in Build stage, to use it inDeploy
stage, you need to download the artifact on Deploy stage. Please notice the download path used.You can check the sample for your reference.
If you still have queries, please show the completed yaml.