Jenkinsfile Sample Utilizing Docker Slave Agent

· Read in about 1 min · (127 words) ·
pipeline {
  agent none

  environment {
    RELEASE_NUMBER = '17.1.1'
    VERSION_NUMBER = VersionNumber(versionNumberString: '17.1.1.${BUILDS_ALL_TIME}')
  }


  stages {
    stage('Checkout from GIT'){
      agent any
      steps {
        script {
          currentBuild.displayName = "#${VERSION_NUMBER}"
        }
        checkout scm
      }
    }
    stage('NUGET package restore') {
      agent { label 'nuget' }
      steps {
            echo 'Restoring nuget packages'
            bat '"%NUGET_PATH%" restore TestSolution.sln'
            dir ('.') {
              stash 'sources'
            }
      }
    }
    stage('Build') {
      agent { label 'dotNET_4.7'}
      steps {
        dir ('.') {
          unstash 'sources'
        }

        bat "\"${tool name: 'Default', type: 'msbuild'}\\msbuild.exe\" TestSolution.sln /p:Configuration=Release /p:Platform=\"Any CPU\""

        dir ('TestSolution/bin') {
          stash 'bins'
        }
        withCredentials([usernamePassword(credentialsId: 'cdd06d32-f11d-446c-8687-3debc9dba901', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
          bat "git tag 'j-${VERSION_NUMBER}'"

          bat "git push http://${GIT_USERNAME}:${GIT_PASSWORD}@git.server.net/TestSolution2.git --tags"
        }
      }
    }
    stage('Archive') {
      agent any
      steps {
        dir ('TestSolution/bin') {
          unstash 'bins'
        }
        archive '**/bin/Release/**.dll'
      }
    }
  }

}