I am trying to create a Pipeline on Jenkins, to automate my build, test and deploy process.
pipeline {
    agent any
    environment {
        myVersion = '0.9'
    }
    tools {
        msbuild '.NET Core 2.0.0'
    }
    stages {
        stage('checkout') {
          steps {
            checkout([$class: 'GitSCM', ...])
          }
        }
        stage('restore') {
            steps {
                bat 'dotnet restore --configfile NuGet.Config'
            }
        }
        stage('build') {
            steps {
                bat 'dotnet build'
            }
        }
        stage('publish') {
            steps {
              ...
            }
        }
    }
}
When trying to run the build, I get this error message from Jenkins:
'dotnet' is not recognized as an internal or external command, operable program or batch file.
What do I have to change to make this environment work?
I added my .NET CORE path etc. to the Jenkins Settings for MSBuild.
What am I missing?
Jenkins itself is written in Java, thus for other project types, you would require consuming those extensions. I will demonstrate usage of the . NET build system in Jenkins workflow to build your . NET apps, as soon as there are changes in the repository.
Solved it like this:
environment {
    myVersion = '0.9'
    dotnet = 'path\to\dotnet.exe'
}
and than replaced my command with the %dotnet% variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With