Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Jenkins with ASP .NET Core

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?

like image 218
AO19 Avatar asked Sep 26 '17 15:09

AO19


People also ask

Can Jenkins be used for .NET applications?

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.


1 Answers

Solved it like this:

environment {
    myVersion = '0.9'
    dotnet = 'path\to\dotnet.exe'
}

and than replaced my command with the %dotnet% variable.

like image 110
AO19 Avatar answered Oct 25 '22 22:10

AO19