How to declare a global variable in Jenkins and use it in an MSBuild task within each individual project -
i converting our ci platform cruisecontrol jenkins, , can't seem figure out seems should relatively simple (disclaimer - i'm no ci or build automation expert, dumped lap , find interesting)
in cruisecontrol, able declare variables this:
<cb:define rootdir="j:\sources\" /> <cb:define logdir="j:\sources\buildlogs" /> <cb:define iisdir="j:\iis\" /> <cb:define artifacts="artifacts\" />
then use them part of msbuild task
<msbuild> <executable>c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe</executable> <workingdirectory>$(rootdir)$(projectname)</workingdirectory> <projectfile>$(projectname).sln</projectfile> <buildargs>/p:builddate="1";outdir="$(iisdir)$(projectname)\bin\\";webprojectoutputdir="$(iisdir)$(projectname)\\"</buildargs> <targets>rebuild;$(projectname)</targets> <timeout>180</timeout> <logger>c:\program files (x86)\cruisecontrol.net\server\thoughtworks.cruisecontrol.msbuild.dll</logger> </msbuild>
if root or iis directories change, can applied projects @ once. have ~60 projects setup, doing project project time consuming. migrating jenkins, msbuild command line arguments (partial sample includes relevant):
outdir="j:\iis\projectname\bin\\";webprojectoutputdir="j:\iis\projectname\\"
the iis directory hard coded. need more this:
outdir="${iis_dir}\projectname\bin\\";webprojectoutputdir="${item_rootdir}\projectname\\"
is there way that? tried configuration slicing plugin, useful, doesn't fit need see
for global variables, need envinject plugin. allows (among other things) setup variables @ global (node) level, @ job level or step. can set variables directly, or properties file, or scripts.
once set, variables available environment variables rest of jenkins , steps (within scope).
for passing arguments msbuild, when configure msbuild step, there option pass "command line arguments" in format /p:param=value.
the "value" environment variable. on windows environment reference %myvar%
so, if configure global global_iis_dir=c:\path\to\iis
using envinject, can reference on command line /p:iis_dir=%global_iis_dir%
Comments
Post a Comment