开发者

CruiseControl.NET and Mounting a Drive

I am running CruiseControl.NET as a service but some of the projects that I am building reference things using a network drive. As In H:... instead of \machine\dir. I can't change the pr开发者_运维技巧oject references. How can I mount the H: drive before the project builds or maybe when CruiseControl starts running?


From a command line, you can call "net use" to set up a mapped drive. You might be able to run this from an exec task before the code is compiled.


I've tested the following .bat file and it worked fine using:
- CruiseControl.Net version 1.5.7256.1
- a .bat file running from an <exec> task.

.bat file

ECHO OFF
NET USE \\Server\data /USER:domain\user password
ECHO ON
C:\utils\robocopy.exe C:\build\data \\Server\data *.*

ccnet.config

 <project name="ProjectName">
    <!-- snip -->
    <tasks>
        <!-- snip -->
        <exec>
            <executable>deploy.bat</executable>
            <baseDirectory>Configuration\</baseDirectory>
            <buildArgs></buildArgs>
            <buildTimeoutSeconds>60</buildTimeoutSeconds>
            <successExitCodes>0,1,2,3,4,5,6,7,8</successExitCodes>
         </exec> 


Notes:
I installed the Cruise Control service using default settings and accounts.
I turn echo off and then on, to prevent user details from being put into build logs.

I got the hint to not use drive letters from this:
Mapping a network drive without hardcoding a drive letter in a batch file

Update: Included ccnet.config syntax


in my ccnet.config:

 <exec>
        <executable>setup_build.cmd</executable>
        <baseDirectory>&BaseDIR;\CruiseControlNET</baseDirectory>
        <buildArgs>&BaseDIR;\AllProjectsTFS</buildArgs>
        <buildTimeoutSeconds>&BuildTimeoutInSeconds;</buildTimeoutSeconds>
 </exec>

And I checked setup_build.cmd under my CruiseControlNet directory in SVN (setup as described in: http://confluence.public.thoughtworks.org/display/CCNET/Configure+CruiseControl.Net+to+Automatically+Update+its+Config+File)

setup_build.cmd contains:

@ECHO OFF

:CHECK_PARAMETERS
IF "%1"=="" GOTO SYNTAX

:PRINT_PARAMETERS
SET BASE_DIRECTORY=%1
ECHO PARAMETERS:
ECHO BaseDirectory: %BASE_DIRECTORY%
ECHO.

:ARTIFACTS_DIRECTORY
ECHO CREATING ARTIFACTS DIRECTORY:
SET ARTIFACTS_DIR=%BASE_DIRECTORY%\Artifacts
ECHO Creating Artifacts Directory in: %ARTIFACTS_DIR%
IF EXIST %ARTIFACTS_DIR% RMDIR /S /Q %ARTIFACTS_DIR%
MKDIR %ARTIFACTS_DIR%
ECHO SUCCESS
ECHO.

:SETUP_NETWORK_DRIVES
ECHO MAPPING NETWORK DRIVES:
IF NOT EXIST H: NET USE H: \\server\share
NET USE
GOTO END

:SYNTAX
ECHO Wrong Arguments:
ECHO SYNTAX: setup_build.cmd [BASE_DIRECTORY]
EXIT /B -1

:END
EXIT /B 0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜