The system cannot find the specified drive in Jenkins

后端 未结 9 2452
半阙折子戏
半阙折子戏 2021-02-15 15:17

I want to copy some files from a network shared drive (mounted at my local machine as drive Z). I have written a Batch file to copy the contents of Z drive into my local drive.

9条回答
  •  一个人的身影
    2021-02-15 15:32

    If you don't want to use Jenkins-plugins or schedule-Tasks here is a "groovy" way:

    By Hand:

    You can use the Groovy Script-Console provided by Jenkins>Manage Jenkins>Script Console and execute the command to map the network-drive within the Jenkins-service. (Must be repeated, once the Jenkins-service is stopped)

    Automation:

    Write your Groovy commands to a file named "init.groovy" and place it in your JENKINS_HOME-directory. So the network-drive gets mapped on Jenkins-startup.

    Groovy Commands - Windows:

    Check available network drives using the Script-Console:

    println "net use".execute().getText()
    

    Your init.groovy would look like this:

    def mapdrive = "net use z: \\\\YOUR_REMOTE_MACHINE\\SHARED_FOLDERNAME"
    mapdrive.execute()
    

提交回复
热议问题