0

I am working on Jenkins Pipeline Script and I have checked-in my jenkinsfile in Git repository and I need to clone to local work space. But by default its cloning to master (Unix) work space but I need it in slave (Windows) work space.

Is there any plugins to change the default Pipeline Script from SCM work space location to slave?

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
Aravind
  • 53
  • 1
  • 8

2 Answers2

0

You can do something like this

pipeline {
agent any
options {
    skipDefaultCheckout()
 }
stages {
    stage('checkout') {
      steps {
            node('windows') {
                 checkout scm
             }
         }
      }
   }
}

OR

pipeline {
agent 'windows'
stages {
stage('build') {
  steps {
         // build
     }
  }
 }
}
Ram
  • 1,154
  • 6
  • 22
  • Thanks for your response, but my requirement is I have my Jenkinsfile in Bitbucket and i have to clone files in Slave workspace before executing the Pipeline Scripts.By default it's taking master workspace but I want jenkinsfile scripts to be stored in Slave workspace. – Aravind Mar 20 '18 at 12:45
  • Is your Jenkinsfile different from the Pipeline script? – Ram Mar 20 '18 at 12:48
0

In my case, the following pipeline configuration skips the default checkout on master, and checkout my code just on Jenkins slave.

node {
  docker.image('php7.1.30:1.0.0').inside {
  skipDefaultCheckout() // this avoid the checkout on master 

    stage("checkout"){
      checkout scm   // here the checkout happens on slave node
    }


    stage('NPM Install'){
      sh label: 'NPM INSTALL', script: "npm install"
      sh label: 'GRUNT INSTALL', script: "npm install -g grunt-cli"
    }

    stage('Executing grunt') {
      sh label: 'GRUNT DEFAULT', script: "grunt default"
    }

 }
}
Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54