I am trying to create a simple pipeline where python application code will be pulled from github enterprise and will be executed on the agent server itself. Here I am using Self hosted agent on a Linux VM.
trigger:
branches:
include:
- master
- refs/tags/*
- feature*
stages:
- stage: Deploy
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/feature')))
jobs:
- job: 'RunDeploymentCommandJob'
displayName: Deploying job
pool:
name: Ppe-Gear-Price-Agent-Pool
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6' # Use Python 3.x
addToPath: true
- script: |
cd gear-price-publisher
# Install dependencies if needed
pip install -r requirements.txt
# Run the Python code
gunicorn -w 1 -b 0.0.0.0:80 controller:app
displayName: 'Run Python Code'
While code is successfully checked out Github Enterprise, UsePythonVersion task is getting failed with the below error for Gihub:
##[warning]You should provide GitHub token if you want to download a python release. Otherwise you may hit the GitHub anonymous download limit.
##[error]Failed to download Python from the Github Actions python registry (https://github.com/actions/python-versions). Error: AggregateError
##[error]Version spec 3.6 for architecture x64 did not match any version in Agent.ToolsDirectory.
Could you please suggest on this.
Thanks
If the Linux agent(mine is ubuntu 20.04) is able to access the python download page
https://github.com/actions/python-versions, you can use the task in pipeline:It will download the python package and try to prepare the
tool cachefolder structure for you:The
tool cachestructure on the agent machine:To resolve the error in the log
./python: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory, we can link it manually via command(change the path to your own):After it's done, run again the pipeline: