0

I found checkoutToSubdirectory in the Jenkins pipeline docs and in the build console I am seeing output saying Running in /home/ec2-user/workspace/projectDir/subDir but then when the first

stage('install/fetch dependencies') {
  steps {

block it gets run in the normal workspace projectDir, not subDir. What else do I need to add to ensure my stages are run in the subDir?

Jeremy
  • 1,717
  • 5
  • 30
  • 49

1 Answers1

-2

The checkoutToSubdirectory don't change the workspace for the build. You can change your workspace by setting WORKSPACE environment at the starting of stages. Use below lines to change workspace

pipeline{
    agent { label 'master' }
    environment { 
    WORKSPACE="${WORKSPACE}/subdir" 
    }
    stages{}
}
Amit Nanaware
  • 3,203
  • 1
  • 6
  • 19
  • 1
    Thanks for your answer @Amit , however, this does not work as intended. If I run `sh "pwd"` in a stage then it will show the script is running in `WORKSPACE` not `WORKSPACE/subdir` – Jeremy Dec 07 '18 at 17:21