Jenkins copy directories/files in a build

27,430

I would guess the mapped drive isn't available in the services context, or that the user executing Jenkins doesn't have access to it. What user is Jenkins running as?

Edit: I think your problem has two aspects:

  1. The user running the Jenkins service isn't allowed to connect to the network.
  2. h: isn't known to the user.

If you haven't modified it, the service is most likely running under the LocalSystem account. You can modify this by running services.msc (or navigate to services via the Windows control panel) and locating the jenkins service. This should resolve the first problem.

The second problem can be resolved by using UNC paths (as you tried above) instead of network drives.

The Jenkins wiki has an article about problems like this: My software builds on my computer but not on Jenkins

Share:
27,430
T.j. Randall
Author by

T.j. Randall

I'm better live....

Updated on February 14, 2020

Comments

  • T.j. Randall
    T.j. Randall over 4 years

    I am trying to copy files out to a network directory during a build, and I keep getting a " No such file or directory" error message.

    Copying to local drive works fine:

    cp -Rf c:/Jenkins/deployments/TW_ISSUE_A/src c:/Jenkins/deployments/TW_ISSUE_A/target
    

    The following all throw the same message:

    cp -Rf c:/Jenkins/deployments/TW_ISSUE_A/src H:/some_dir
    
    cp -Rf c:/Jenkins/deployments/TW_ISSUE_A/src H:\some_dir
    
    cp -Rf c:/Jenkins/deployments/TW_ISSUE_A/src //Hubbell/MISGenl/some_dir
    
    cd c:/Jenkins/deployments/TW_ISSUE_A/src
    rsync -avuzb //Hubbell/MISGenl/Projects/Tronweb/TronwebBuilds/test/ora/sql/
    
    cp -Rf c:/Jenkins/deployments/TW_ISSUE_A/src /cygdrive/h/some_dir
    

    I've even created a shell script to call from Jenkins, but I continue to receive that message.

    #!/bin/bash
    
    url="http://as-test02:8080/job/TW_ISSUE_A_BUILD/lastSuccessfulBuild/artifact/bui
    ld-TW_ISSUE_A_BUILD.tar";
    
    remote_stage_dir="/cygdrive/h/some_dir"
    
    #fetch the artifacts
    
    (cd "$remote_stage_dir" && wget "$url" && tar xvf build-TW_ISSUE_A_BUILD.tar dat
     java ora && rm -rf *.tar && cp -r ./ora/* ../INTEGRATION)
    

    Is there any way to copy files out to a mapped drive on the build machine?

    Thank you!!

  • T.j. Randall
    T.j. Randall about 13 years
    Jenkins is running on a VM server - I (trandal) was logged in when the service was started. I didn't say it above, but I can use any/all commands (and run the script) when I'm on the server. I'm going to go look it up - not sure what you mean by "services context"
  • T.j. Randall
    T.j. Randall about 13 years
    Thank you very much for the clarification! I updated Jenkins to run under a named user, as well as mapped a drive per the Jenkins wiki link. Thank you again!!