Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set environment variable in Cruisecontrol

How can I set environment variable in Cruisecontrol?

If I try to do it like this:

<exec command="set PATH="
                workingdir="d:\AppLiteNew\Projects\"
                args = "%PATH%;D:\QtSDK\mingw\bin\"/> 

it does not work, all I got is:

[cc]Dec-13 13:30:28 ExecBuilder - Could not execute command: set PATH= with arguments: %PATH%;D:\QtSDK\mingw\bin\

like image 331
unresolved_external Avatar asked Feb 23 '23 03:02

unresolved_external


2 Answers

Firstly, you use the exec command wrong

The command is set and its argument should be PATH=%PATH%;D:\QtSDK\mingw\bin\

This should work:

<exec command="set"
  workingdir="d:\AppLiteNew\Projects\"
  args = "PATH=%PATH%;D:\QtSDK\mingw\bin\"/> 

Secondly, it won't have an effect

The Path you set, will only be available to the shell/command that is executed by invoking exec. After the call it will not be available to further commands /executions.
You didn't state what use case you have or where you need the variable, therefore I can only guess, what you could do. You could do the following:

  1. Set the Path directly in Windows, for everything (if that is okay)
  2. Edit the batch file, that starts cruisecontrol and set the PATH there
  3. Create a batch file for the command that needs the PATH and set the PATH there.
  4. Some ant-tasks allow to specify environment variables for them
like image 91
oers Avatar answered Mar 27 '23 07:03

oers


In CruiseControl.net you can set them in the configuration of the task. They go in an environment block:

<environment>
    <variable name="MyVar2" value="Var2Value" />
</environment>

Here's a full sample:

<msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
    <workingDirectory>C:\dev\ccnet</workingDirectory>
    <projectFile>CCNet.sln</projectFile>
    <buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
    <targets>Build;Test</targets>
    <timeout>900</timeout>
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    <environment>
        <variable name="MyVar2" value="Var2Value" />
    </environment>
 </msbuild>
like image 23
Martynnw Avatar answered Mar 27 '23 06:03

Martynnw