Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What shall I use for the input 'githubToken' of Azure DevOps Pipeline task UsePythonVersion@0

I have a self-hosted Azure DevOps Pipeline build agent and would like to download and install Python from the Github repository if it is not already available in the agent tools directory.

The official documentation for the Azure DevOps pipeline task UsePythonVersion@0 states about the input 'githubToken':

githubToken: # string. Optional. Use when disableDownloadFromRegistry = false GitHub token for GitHub Actions python registry.

I am not familiar with GitHub actions and am confused regarding what I should provide for the githubToken input. It is a PAT? Or does it refer to the GITHUB_TOKEN? Where shall I obtain such token so that my pipeline can successfully download Python from GitHub.

The error I experience at the moment is:

##[error]Failed to download Python from the Github Actions python registry (https://github.com/actions/python-versions). Error: Error: unable to get local issuer certificate
like image 873
oli Avatar asked Aug 05 '26 20:08

oli


2 Answers

This task will fail if no Python versions are found in Agent.ToolsDirectory.

To use this task with self-hosted agent, you could follow this link.

First, you could download the appropriate installer from Python.org

I downloaded python-3.7.9-amd64.exe for test.

Then you could run command line (CMD run as administrator) to install the python python-3.7.9-amd64.exe /quiet InstallAllUsers=0 TargetDir={agentinstallPath\_work\_tool}\Python\3.7.9\x64 Include_launcher=0

enter image description here

Remember to switch to the folder which contains python-3.7.9-amd64.exe enter image description here

At last, you need to create an empty {platform}.complete file.

$AGENT_TOOLSDIRECTORY/
    Python/
        {version number}/
            {platform}/
                {tool files}
            {platform}.complete

enter image description here

After restarting the self-hosted agent, pipeline run well.

steps:
- task: UsePythonVersion@0
  displayName: 'Use Python 3.7.9'
  inputs:
    versionSpec: 3.7.9
like image 113
Jiawei Shi - MSFT Avatar answered Aug 09 '26 10:08

Jiawei Shi - MSFT


[error]Failed to download Python from the Github Actions python registry

this error might appear also in case if the file was downloaded, but there were errors with installing python from downloaded ".zip" archive. Thus it is necessary to provide full log and not only name of the error.

Back to your other question. To get a token open "Github.com":

  • press on the upper left icon with your avatar
  • press "Settings" in the drop down
  • On the left in the bottom you'll see "Developer Settings"
  • click on "Personal Access tokens" and create any of two token types

or try this url: https://github.com/settings/tokens?type=beta

like image 36
Johnny Cheesecutter Avatar answered Aug 09 '26 10:08

Johnny Cheesecutter