I am trying to build a .NET application using Jenkins. The Jenkins instance is running in a Docker container.
My Jenkinsfile is as follows:
pipeline {
You can set the HOME
environment variable as @colmulhall suggested, but then you will set the docker container home directory to /tmp
.
To do it in "dotnet"
way set the environment variable DOTNET_CLI_HOME
:
environment {
DOTNET_CLI_HOME = "/tmp/DOTNET_CLI_HOME"
}
Or before calling dotnet
run:
export DOTNET_CLI_HOME="/tmp/DOTNET_CLI_HOME"
A sample Jenkins pipeline code taken from https://www.jenkins.io/doc/pipeline/tour/environment/
Look how DOTNET_CLI_HOME
is defined in the environment
section:
pipeline {
agent {
label '!windows'
}
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
DOTNET_CLI_HOME = "/tmp/DOTNET_CLI_HOME"
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}
There are many ways to achieve this. If you are using docker, maybe a better way is defining the environment variable DOTNET_CLI_HOME
in the docker image.