Robocopy ERROR 3 (0x00000003) Accessing Source Directory C:\172.1.0.56\gen\

Problem

Robocopy prepends drive letter on filepaths even when excute on Jenkins

ERROR 3 (0x00000003) Accessing Source Directory C:\172.1.0.56\gen\
The system cannot find the path specified.
  • Wrong Path: C:\128.1.0.56\gen\
  • True Path: \\10.20.31.56\gen\

How to Fix ?

In jenkinsfile add slash (/), before network path

  • before
pipeline {
    ....
    environment {
        BASE_PATH = pwd();
        DC_PATH = "\\172.1.0.56\\genversion";
        DR_PATH = "\\10.20.31.56\\genversion";
    }
    stages {
       stage('GEN BUILD REQUEST') {
          steps {
              .. YOUR PIPELINE LOGIC
                powershell(returnStdout: true, script: """ robocopy $DC_PATH $DR_PATH /e /xo /z 
                                                           Exit 0 
                                                       """)
                echo "Sync New File DR > DC"
                powershell(returnStdout: true, script: """ robocopy $DR_PATH $DC_PATH /e /xo /z 
                                                           Exit 0 
                                                       """)
          }
       }
    }
}
  • after add slash (/)
pipeline {
    ....
    environment {
        BASE_PATH = pwd();
        DC_PATH = "/\\172.1.0.56\\gen";
        DR_PATH = "/\\10.20.31.56\\gen";
    }
    stages {
       stage('GEN BUILD REQUEST') {
          steps {
              .. YOUR PIPELINE LOGIC
                echo "Sync New File DC > DR"
                powershell(returnStdout: true, script: """ robocopy $DC_PATH $DR_PATH /e /xo /z 
                                                           Exit 0 
                                                       """)
                echo "Sync New File DR > DC"
                powershell(returnStdout: true, script: """ robocopy $DR_PATH $DC_PATH /e /xo /z 
                                                           Exit 0 
                                                       """)
          }
       }
    }
}


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.