Dotnet-outdated Permission Denied

Viewed 56

Im using an a dotnet image in jenkins in order to execute dotnet-outdated command

here is my image code

FROM /baseimages/microsoft/dotnet/core/sdk:6.0-alpine  //this link is private i cannot share but he gives the dotnet image


RUN dotnet tool install --global dotnet-outdated-tool --version 4.1.0
ENV PATH="$PATH:/root/.dotnet/tools"


ENTRYPOINT ["sh"]

i get the image from harbor, when i tried the image on docker, the command run without a problem, but when i try it on jenkins it doesnt work

here is the code in jenkins

stage('getFolder') {                        
                    container('dotnet-outdated') {
                        sh """
                        dotnet --version
                        dotnet-outdated --version
                    """
                    }
                }

the dotnet --version works fine but the dotnet outdated doesnt work this is the error error

the environment is already set

envVars: [
            envVar(key: 'DOTNET_CLI_HOME', value: '/tmp/dotnet_cli'),
        ],
1 Answers

You are using --global see msdn for full reference( https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders)

Your package is installed at ~/.nuget(.dotnet)/packages(tools).

Which is most likely can not be accessed because of one of the following:

  • no access for user running to the PATH
  • the PATH is not in $PATH variables list

You can check actual PATHs with:

dotnet nuget locals all --list

Generally to avoid this sort of issue I would use tool-path and provide custom path for installation (i.e. ./tools, avoiding user folder, so there is no need to have access to root in runtime) in combination with adding destination folder to $PATH list. Afterwards a permissions for folder need to be updated (read/write with chmod).

EDIT 1: Tested setup

FROM mcr.microsoft.com/dotnet/sdk:6.0


RUN dotnet tool install --global dotnet-outdated-tool --version 4.1.0
ENV PATH="$PATH:/root/.dotnet/tools"

RUN dotnet help

ENTRYPOINT [ "dotnet-outdated" ]

Output: Discovering projects...The directory '/' does not contain any solutions or projects.

Related