This Question is Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
2 Replies Last post: 2009-4-22 下午1:07 by Enrico Dittmann  
Enrico Dittmann Newbie 8 posts since
2009-2-11
Currently Being Moderated

2009-4-21 下午3:00

Access remote system from ant script failes

Hello *,


we have got an ant script which should access a remote system after building a java project to distribute it.

The target in our build.xml looks like this:


    <!-- ==================== Run deployment Target ============================= -->
    <target name="deployment" description="deploy project to test server">

 

        <!-- kill running test server on remote system -->
        <exec executable="cmd.exe">
            <arg line="/c taskkill /S ip.of.remote.system /U user_of_remote_system /P password_of_remote_system /IM cmd.exe /T"/>
        </exec>

 

        <!-- build, unzip and other stuff -->
        [ ... ]

 

        <!-- delete old folders on test server-->
        <delete dir="${testserver.mappeddir}/${app.name}" />
        [ ... ]

 

        <!-- move folders to test server (name without version number) -->
        <move file="${tempdir}/${dist.name}" tofile="${testserver.mappeddir}/${app.name}"/>
        [ ... ]
        <delete dir="${tempdir}" />

 

        <!-- start test server -->
        <exec executable="psexec.exe">
            <arg line="\\ip.of.remote.system -d -i -u user_of_remote_system -p password_of_remote_system -w D:/Test-Server cmd /c &quot;1 Test-Server starten.lnk&quot;"/>
        </exec>

 

    </target>

 

${testserver.mappeddir} points to a folder on the remote system (is mapped as a network drive Z: on the build system). The network drive connection is established by an admin user on each startup/ logon. Running the script from command line within this user account works just fine but running it from TeamCity the build fails with the following error message:

 

[11:50:48]: [deployment] exec (38s)
[11:51:26]: [exec] FEHLER: Anmeldung fehlgeschlagen: unbekannter Benutzername oder falsches Kennwort. [error: logon failed. unknown user or password - this is an error caused by the first exec command]
[11:51:26]: [exec] Result: 1
[11:52:02]: [deploymentvistahro] move
[11:52:02]: [move] Failed to copy C:\TeamCity\buildAgent\work\TestServer_DeploymentBuild\temp\TestServer-1.0.15\bin\lib\commons-cli-1.0.jar to Z:\TestServer\bin\lib\commons-cli-1.0.jar due to Z:\TestServer\bin\lib\commons-cli-1.0.jar (Das System kann den angegebenen Pfad nicht finden) [system can not locate given path]

 

It seems that TeamCitys Build service runs on the local system account and has no rights to access the remote system (or the mapped drive due to its establishment by a specific user). So we changed the service "TeamCity Build Agent Service" to run with the admin user which leads to another error message:

 

[11:57:06]: [deployment] exec
[11:57:06]: [exec] Der Befehl "taskkill" ist entweder falsch geschrieben oder
[11:57:06]: [exec] konnte nicht gefunden werden. [the commant "taskkill" either is written wrong or could not be located]
[11:57:06]: [exec] Result: 1
[11:57:45]: [deploymentvistahro] move
[11:57:45]: [move] Failed to copy C:\TeamCity\buildAgent\work\TestServer_DeploymentBuild\temp\TestServer-1.0.15\bin\lib\commons-cli-1.0.jar to Z:\TestServer\bin\lib\commons-cli-1.0.jar due to Z:\TestServer\bin\lib\commons-cli-1.0.jar (Das System kann den angegebenen Pfad nicht finden) [system can not locate given path]

Why it is possible to access the remote system while running the script from the command line but not from tc ant build runner? I can imagine that there could be problems using the network drive but I was sure the first exec command in the script should work in every scenario. Any suggestions?

Thanks in advance for help.

Regards
Enrico
Pavel Sher JetBrains 2,081 posts since
2008-3-6
Currently Being Moderated
2009-4-21 下午8:49 in response to: Enrico Dittmann
Re: Access remote system from ant script failes

Windows service cannot access mapped network drives. This is limitation of Windows OS. There are two workarounds:

- run agent via agent.bat

- use UNC paths to access network directories

More Like This

  • Retrieving data ...