作者:长沙祛疤--欣奕除疤_998 | 来源:互联网 | 2022-11-27 17:29
我正在尝试使用Jenkins构建.NET应用程序。Jenkins实例在Docker容器中运行。
我的Jenkinsfile如下:
pipeline {
agent {
docker {
image 'microsoft/dotnet:2.1-sdk'
registryUrl 'https://index.docker.io/v1/'
}
}
stages {
stage('Build') {
steps {
sh 'dotnet build MyApplication/Application.csproj -c Release -o /app'
}
}
stage('Test') {
steps {
sh 'dotnet test MyApplication/Application.csproj -c Release -r /results'
}
}
}
}
当我尝试构建时,在Jenkins构建输出中看到以下错误:
System.UnauthorizedAccessException: Access to the path '/.dotnet' is denied. ---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at System.IO.FileSystem.CreateDirectory(String fullPath)
at System.IO.Directory.CreateDirectory(String path)
at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateDirectory(String path)
at Microsoft.DotNet.Configurer.FileSentinel.Create()
at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
看来'.dotnet'文件夹在Docker容器中受到保护。有没有办法获得对此的读写权限,或者改变它的位置?当我猛扑到容器中时,似乎找不到该文件夹。
谢谢你的帮助。