Azure-pipelines-tasks: Bash@3 doesn't have permissions to execute NuGet.exe installed by agent

Created on 23 Sep 2020  路  4Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Bash@3

Environment

  • Server - Azure Pipelines or TFS on-premises?

    • If using TFS on-premises, provide the version: Azure DevOps Server Version Dev17.M153.5

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number:

  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name:-

    • If using private agent, provide the OS of the machine running the agent and the agent version: Ubuntu 16.04/2.153.1

Issue Description

Bash inline script doesn't have execution rights on NuGet.exe installed by NuGetToolInstaller@1

I feel like this deserves some background: Only reason for going the bash-route is because I need to pass -Suffix conditionally to nuget. I tried several ways with the NuGetCommand task but since the suffix value is created at runtime (from MSBuild using git commit height amongst) expressions couldn't help me since they are evaluated at compile time.

Task logs

##[debug]Evaluating condition for step: '[Docker config] Pack configuration file'
##[debug]Evaluating: succeededOrFailed()
##[debug]Evaluating succeededOrFailed:
##[debug]=> True
##[debug]Result: True
##[section]Starting: [Docker config] Pack configuration file
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.151.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
##[debug]agent.TempDirectory=/azp/agent/_work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_SCRIPT
##[debug]loading INPUT_WORKINGDIRECTORY
##[debug]loading INPUT_FAILONSTDERR
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 7
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]check path : /azp/agent/_work/_tasks/CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9/2.151.1/task.json
##[debug]adding resource file: /azp/agent/_work/_tasks/CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9/2.151.1/task.json
##[debug]system.culture=en-US
##[debug]failOnStderr=false
##[debug]script=ARGS="configuration.nuspec -Version 1.0.0 -OutputDirectory /azp/agent/_work/1/a"
if [ ! -z docker-env.0.181699 ]; then
  ARGS="${ARGS} -Suffix docker-env.0.181699"
fi
nuget.exe pack $ARGS
##[debug]workingDirectory=/azp/agent/_work/1/s
##[debug]check path : /azp/agent/_work/1/s
Generating script.
##[debug]Agent.Version=2.153.1
##[debug]agent.tempDirectory=/azp/agent/_work/_temp
##[debug]check path : /azp/agent/_work/_temp
========================== Starting Command Output ===========================
##[debug]which 'bash'
##[debug]found: '/bin/bash'
##[debug]which 'bash'
##[debug]found: '/bin/bash'
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]/bin/bash arg: --noprofile
##[debug]/bin/bash arg: --norc
##[debug]/bin/bash arg: /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
##[debug]exec tool: /bin/bash
##[debug]arguments:
##[debug]   --noprofile
##[debug]   --norc
##[debug]   /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
[command]/bin/bash --noprofile --norc /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
/azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh: line 5: /azp/agent/_work/_tool/NuGet/5.4.0/x64/nuget.exe: Permission denied
##[debug]Exit code 126 received from tool '/bin/bash'
##[debug]STDIO streams have closed for tool '/bin/bash'
##[error]Bash exited with code '126'.
##[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '126'.
##[debug]task result: Failed
##[debug]Processed: ##vso[task.complete result=Failed;done=true;]
##[section]Finishing: [Docker config] Pack configuration file

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

##[debug]Evaluating condition for step: '[Docker config] Pack configuration file'
##[debug]Evaluating: succeededOrFailed()
##[debug]Evaluating succeededOrFailed:
##[debug]=> True
##[debug]Result: True
##[section]Starting: [Docker config] Pack configuration file
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.151.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
##[debug]agent.TempDirectory=/azp/agent/_work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_SCRIPT
##[debug]loading INPUT_WORKINGDIRECTORY
##[debug]loading INPUT_FAILONSTDERR
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 7
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]check path : /azp/agent/_work/_tasks/CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9/2.151.1/task.json
##[debug]adding resource file: /azp/agent/_work/_tasks/CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9/2.151.1/task.json
##[debug]system.culture=en-US
##[debug]failOnStderr=false
##[debug]script=ARGS="configuration.nuspec -Version 1.0.0 -OutputDirectory /azp/agent/_work/1/a"
if [ ! -z docker-env.0.181699 ]; then
  ARGS="${ARGS} -Suffix docker-env.0.181699"
fi
nuget.exe pack $ARGS
##[debug]workingDirectory=/azp/agent/_work/1/s
##[debug]check path : /azp/agent/_work/1/s
Generating script.
##[debug]Agent.Version=2.153.1
##[debug]agent.tempDirectory=/azp/agent/_work/_temp
##[debug]check path : /azp/agent/_work/_temp
========================== Starting Command Output ===========================
##[debug]which 'bash'
##[debug]found: '/bin/bash'
##[debug]which 'bash'
##[debug]found: '/bin/bash'
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]/bin/bash arg: --noprofile
##[debug]/bin/bash arg: --norc
##[debug]/bin/bash arg: /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
##[debug]exec tool: /bin/bash
##[debug]arguments:
##[debug]   --noprofile
##[debug]   --norc
##[debug]   /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
[command]/bin/bash --noprofile --norc /azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh
/azp/agent/_work/_temp/ed2adc20-9996-436e-8861-6916f5acfb63.sh: line 5: /azp/agent/_work/_tool/NuGet/5.4.0/x64/nuget.exe: Permission denied
##[debug]Exit code 126 received from tool '/bin/bash'
##[debug]STDIO streams have closed for tool '/bin/bash'
##[error]Bash exited with code '126'.
##[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '126'.
##[debug]task result: Failed
##[debug]Processed: ##vso[task.complete result=Failed;done=true;]
##[section]Finishing: [Docker config] Pack configuration file
ABTT bug question

All 4 comments

Hi @joacar, could you please try to use chmod a+x $(which nuget.exe) command before nuget.exe call?

Hi @sdobrodeev

Will check if that works. I added mono nuget.exe ... (after installing it on our agent) and after that it works. Don't know if that particular change was what made it work since I also moved the download parts to the same script that executes nuget.

Hi @joacar This problem is still actual to you?

@sdobrodeev Closing it and will revisit if I stumble upon this again.

Was this page helpful?
0 / 5 - 0 ratings