0

Created a self-hosted agent on a on-prem server which is up and running on Azure. Added pool info to azure_pipelines.yml

pool:
  name: TestPool
  demands:
  - agent.name -equals Test_Agent_01

running the pipeline throws the error for below tasks in yml file

 - task: UsePythonVersion@0
   inputs:
     versionSpec: '3.x'
     addToPath: true
     architecture: 'x64'
   displayName: 'Use Python 3.x'

and

- task: DownloadPackage@1
  inputs:
    packageType: 'pypi'
    feed: 'feedid'
    view: 'viewid'
    definition: 'defid'
    version: '0.0.2'
    downloadPath: '$(Build.SourcesDirectory)'

Error While running the pipeline

Starting: Use Python 3.x
==============================================================================
Task         : Use Python version
Description  : Use the specified version of Python from the tool cache, optionally adding it to the PATH
Version      : 0.220.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/use-python-version
==============================================================================
node:internal/fs/utils:347
    throw err;
    ^

Error: EPERM: operation not permitted, lstat 'path'
    at Object.realpathSync (node:fs:2538:7)
    at toRealPath (node:internal/modules/cjs/loader:405:13)
    at Function.Module._findPath (node:internal/modules/cjs/loader:548:24)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at Module._preloadModules (node:internal/modules/cjs/loader:1303:12)
    at loadPreloadModules (node:internal/bootstrap/pre_execution:583:5)
    at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:95:3)
    at node:internal/main/run_main_module:7:1 {
  errno: -4048,
  syscall: 'lstat',
  code: 'EPERM',
  path: 'path'
}
##[error]Exit code 1 returned from process: file name "filename' arguments  'arguments'

Can I know what is the possible configuration or permissions missing here?

speed0001
  • 45
  • 3

1 Answers1

0

I tried downloading python feed packages in my yaml pipeline with self hosted agent and it was successful, Refer below:-

I created one python package and pushed it in my feed by referring this Document

enter image description here

enter image description here

Click on get tools and install python and this package in your local machine where your package exist or in your self hosted machine:-

pip install twine keyring artifacts-keyring

Create .pypirc file by running this command in your terminal:-

notepad %USERPROFILE%\.pypirc

My .pypirc

[distutils]
Index-servers =
  xxxx38

[xxxx38]
Repository = https://pkgs.dev.azure.com/xxxxxxx38/_packaging/sid24desai0738/pypi/upload/
username=xxxx@outlook.com
password=<PAT-Token>

And refer the steps below to publish the package in the Azure Devops artifact:-

enter image description here

enter image description here

enter image description here

Now, Run the yaml script below, Make sure you select the correct parameters like below:-

trigger:
- main

pool:
  name: Default

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

- task: DownloadPackage@1
  inputs:
    packageType: 'pypi'
    feed: '/0590083e-4925-4431-a915-0197b5bbd1e0'
    view: '2e471084-fe8a-4c0a-a747-4300d15ed8ed'
    definition: 'e70503fb-4e32-4e34-ac66-1ef44e71a7c8'
    version: '0.1'
    downloadPath: '$(System.ArtifactsDirectory)'

enter image description here

There's a limitation on using Use Python version task in Azure Devops pipeline for self hosted agents, Refer here and the prerequisite which states:-

On self-hosted agents, downloading Python versions is not supported. If no Python versions are identified in Agent, this task will fail if no specified python version is found in Agents.ToolsDirectory. Self hosted agent needs to be configured with Agents.ToolsDirectory.

An alternative is to add the python executable with your script as given in this SO thread answer by Levi Lu-MSFT

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11