I have a github repository with a declarative pipeline Jenkinsfile. The workingdirectory on my node contains subdirectories.
The project is a simple empty linkx docker project created with visual studio 2017 and .net core 2.1. It executes on my windows 7 machine normally and has a hello world web page.
I am unable to build the Dockerfile on jenkins. I can start the Dockerfile build using dir(...){}
. The failing step is always
COPY ["MyProject/MyProject.csproj", "MyProject/"]
This step requires the relative path to be in MySolution
.
The file Workspace/MySolution/MyProject/MyProject.csproj
exists
The error Message is that Workspace/MyProject/MyProject.csproj
does not exist.
I searched exhaustively using google and stackoverflow. Among the things I tries are combinations of sh
commands, dir
syntax, options on docker build like -f
. Some of them were straigth up failures and the best results I had ran into the COPY
step issue.
One example of a failing step in the Jenkinsfile would be:
dir("MySolution/MyProject")
{
script
{
docker.build("MyProject", ".")
}
}
This fails with the COPY
issue from above.
I have seen questions on so that seem to not quite apply here and which solutions did not transfer to this issue.
It turns out I ended up really close to the solution of my issue. This fixed my sub folder problem:
dir("MySolution")
{
script
{
docker.build("MyProject", "-f ./MyProject/Dockerfile .")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.