Search code examples
jenkinsjenkins-pluginsjenkins-job-dsl

How to only git pull in particular folder from a repository using Jenkins?


I have a folder inside D:/TestFolder/ Now I need to git pull inside TestFolder using Jenkins every time I trigger a job. How is it possible?

Can anyone guide me on Jenkins git pull in a particular folder?


Solution

  • git plugins for Jenkins come with that option -

    If you are using Jenkins freestyle job, enter image description here

    If you are using Jenkins scripted pipeline , It will be like

    node() {
      stage('checkout') {
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'sub_folder']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credentialId', url: 'http://repourl.net/x.git']]])
    
      }
    }