Hi all,
We have a problem with a build using the Octopus Jenkins Plugin. The problem is about the location of the .NET SDK which is not found by the Octopus CLI tool. It’s not at the default location (/usr/share/dotnet) and for some reason the environment variable DOTNET_ROOT seems to have no effect even when it’s set.
I’ve simplified our pipeline as much as I could to this:
#!groovy
@Library('pipeline-library')_
pipeline {
agent { label 'linux-slaves && dotnet' }
environment {
DOTNET_ROOT = "/opt/jenkins/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/dotnet-sdk-3.1/"
PATH = "/opt/jenkins/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/dotnet-sdk-3.1/:$PATH"
}
stages {
stage('Pack') {
steps {
script {
sh "printenv DOTNET_ROOT"
sh "dotnet --version"
sh "dotnet tool install --tool-path ./tools --add-source https://internal-artifactory-nuget-proxy Octopus.DotNet.Cli"
sh "./tools/dotnet-octo version"
}
octopusPack \
toolId: 'Default', \
packageId: "TestPackage", \
packageFormat: 'zip', \
sourcePath: './src/', \
outputPath: './artifacts', \
packageVersion: "1.0.0" \
}
}
}
post {
cleanup {
script {
cleanWs()
}
}
}
}
And this is the build log:
[Pipeline] sh
+ printenv DOTNET_ROOT
/opt/jenkins/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/dotnet-sdk-3.1/
[Pipeline] sh
+ dotnet --version
3.1.402
[Pipeline] sh
+ dotnet tool install --tool-path ./tools --add-source https://internal-artifactory-nuget-proxy Octopus.DotNet.Cli
You can invoke the tool using the following command: dotnet-octo
Tool 'octopus.dotnet.cli' (version '7.4.4') was successfully installed.
[Pipeline] sh
+ ./tools/dotnet-octo version
7.4.4
[Pipeline] }
[Pipeline] // script
[Pipeline] octopusPack
[ervice_feature_pipeline-test-tom] $ ./tools/dotnet-octo pack --id TestPackage --version 1.0.0 --format zip --basePath ./src/ --include ** --outFolder ./artifacts
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/opt/jenkins/workspace/ervice_feature_pipeline-test-tom/tools/.store/octopus.dotnet.cli/7.4.4/octopus.dotnet.cli/7.4.4/tools/netcoreapp3.1/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=rhel.7-x64
INFO: Octopus CLI exit code: 131
ERROR: Unable to create or deploy release. Please check the build log for details on the error.
As you can see, we first set the environment variable DOTNET_ROOT to the location where the .NET SDK is installed. It’s printed out with “printenv” and the installation of the CLI tool is successful. Even the execution of the tool “dotnet-octo” works, when calling it from the shell.
But now the CLI tool should be used by the plugin (octopusPack). So we configured it this way:
The tool is found, but it looks like the environment variable DOTNET_ROOT is not set for the plugin. Is this a bug within the plugin? Or did we miss a configuration?
Thank you for your help
Tom