Jenkins: no tool named MSBuild found

前端 未结 5 1195
闹比i
闹比i 2021-02-02 02:25

Setting up a Pipeline build in Jenkins (Jenkins 2.6), copying the sample script for a git-based build gives: \"no tool named MSBuild found\". I have set MSBuild Tool in Ma

5条回答
  •  春和景丽
    2021-02-02 02:37

    In Declarative Pipeline syntax, the tooling for MSBuild is a little clunkier. Here's how I've had to handle it, using a script block:

    pipeline {
      agent { 
        label 'win-slave-node'
      }
      stages {
        stage('Build') {
          steps {
            script {
              def msbuild = tool name: 'MSBuild', type: 'hudson.plugins.msbuild.MsBuildInstallation'
              bat "${msbuild} SimpleWindowsProject.sln"
            } 
          } 
        } 
      } 
    } 
    

    In the older Scripted Pipeline syntax, it could be like this:

    node('win-slave-node') {
      def msbuild = tool name: 'MSBuild', type: 'hudson.plugins.msbuild.MsBuildInstallation'
    
      stage('Checkout') {
        checkout scm
      }
    
      stage('Build') {
        bat "${msbuild} SimpleWindowsProject.sln"
      }
    }
    

提交回复
热议问题