CI/CD Overview
Ci/CD Overview
.Net
Full enchallada
@Echo OFF
SET APPNAME=MySampleHelloWorldApp
SET PARAMETERSPATH="%WORKSPACE%\%APPNAME%\parameters.xml"
SET SOLUTIONORPROJECTNAME=%APPNAME%.sln
SET DEPLOYMENTOUTPUTPATH=%WORKSPACE%\Deployment\output
SET MAINDLLPATH=%DEPLOYMENTOUTPUTPATH%\%APPNAME%.Startup.exe
SET UNITTESTDLLPATH="test/%APPNAME%.Test.Unit/bin/Release/%APPNAME%.Test.Unit.dll"
SET DBPACPATH1=%WORKSPACE%\src\%APPNAME%.Database\bin\Release\%APPNAME%.Database.dacpac
cd %workspace%\
REM Needed for .net 4.6 and below
CALL "%JENKINS_HOME%\userContent\CompileNet\ConfigTransforms.bat" %PARAMETERSPATH%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### CONFIGTRANSFORMS Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\Build.bat" %SOLUTIONORPROJECTNAME%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### BUILD Failed ##### exit /B 1
REM - Needed to properly package for deployment to azure
CALL "%JENKINS_HOME%\userContent\CompileNet\package.bat" "%WORKSPACE%\Deployment\output"
REM IF %ERRORLEVEL% NEQ 0 echo ERROR ##### Package Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\DbPack.bat" "%DBPACPATH1%"
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### Db script Move Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\VersionInfo.bat" "%MAINDLLPATH%" %BUILD_NUMBER%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### VERSION Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\FxCop.bat" %MAINDLLPATH%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### FXCOP Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\Test.bat" %UNITTESTDLLPATH%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### TEST Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\CodeCoverage.bat" "%WORKSPACE%\TestResults" "%WORKSPACE%\TestResults\vstest.coveragexml"
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### Code Coverage Failed ##### exit /B 1
CALL "%JENKINS_HOME%\userContent\CompileNet\Documentation.bat"
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### DOCUMENTATION Failed ##### exit /B 1
ConfigTransforms.bat
Msdeploy parameters.xml and setparameters.xml
@ECHO OFF
SET XMLMERGE="C:\Program Files (x86)\Jenkins\userContent\xmlmerge\MergeXmlFiles.exe"
SET GLOBALPARAMS="%JENKINS_HOME%\userContent\Transforms\Global_Parameters.xml"
@Echo INFO BEGIN CONFIGTRANSFORMS %JOB_NAME% %TIME%
@Echo %XMLMERGE% -p %1 -c "%GLOBALPARAMS%" -o %1
%XMLMERGE% -p %1 -c %GLOBALPARAMS% -o %1
IF %ERRORLEVEL% NEQ 0 @ECHO ERROR ##### CONFIGTRANSFORMS Failed ##### && exit /B 1
@Echo INFO END CONFIGTRANSFORMS %JOB_NAME% %TIME%
Build.Bat
Using MSBUILD.EXE command line to create package.zip that can be deployed via msdeploy.exe (aka WebDeploy)
@Echo OFF
SET SOLUTIONPATH=%1
SET VERBOSITY=%2
SET DBPACPATH=%3
:: diagnostic
:: normal
@Echo Determine Overriding VERBOSITY
set verbosityresult=false
if [%VERBOSITY%]==[] set verbosityresult=true
if [%VERBOSITY%]==[""] set verbosityresult=true
if "%verbosityresult%" == "true" (
@Echo Use default VERBOSITY
SET VERBOSITY=normal
)ELSE (
@Echo Overriding VERBOSITY
SET VERBOSITY=%VERBOSITY%
)
SET MSBUILDCOMMAND="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /m:2 /nologo /v:n /maxcpucount /p:Configuration=Release /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="%WORKSPACE%\Deployment\Package.zip" /p:PublishOutputPathNoTrailingSlash="%WORKSPACE%\Deployment\output" /p:Platform="Any CPU" /p:CodeContractsRunCodeAnalysis=false,RunCodeAnalysis=Never,CodeContractsReferenceAssembly=DoNotBuild /fileLogger /fileLoggerParameters:LogFile=MSBuild.log;Append;Verbosity=%VERBOSITY%;Encoding=UTF-8 %ADDITIONALBUILDPARAMS%
@Echo INFO BEGIN NUGET RESTORE %JOB_NAME% %TIME%
@Echo nuget.exe restore -source "https://iwg-nugetserver.azurewebsites.net/nuget;https://api.nuget.org/v3/index.json"
nuget.exe restore -source "https://iwg-nugetserver.azurewebsites.net/nuget;https://api.nuget.org/v3/index.json"
IF %ERRORLEVEL% NEQ 0 @ECHO ERROR ##### RESTORE Failed ##### && exit /B 1
@Echo INFO END NUGET RESTORE %JOB_NAME% %TIME%
@Echo INFO BEGIN BUILD %JOB_NAME% %TIME%
@Echo %MSBUILDCOMMAND% %SOLUTIONPATH%
%MSBUILDCOMMAND% %SOLUTIONPATH%
IF %ERRORLEVEL% NEQ 0 @ECHO ERROR ##### BUILD Failed ##### && exit /B 1
@Echo INFO END BUILD %JOB_NAME% %TIME%
Package.bat
@Echo INFO BEGIN PACKAGE %JOB_NAME% %TIME%
SET APPLICATIONCONTENTPATH=%1
CD "%WORKSPACE%"
MD Deployment
SET RUNCMD=%MSDEPLOYCOMMAND% -verb:sync -source:contentPath=%APPLICATIONCONTENTPATH% -dest:package="%WORKSPACE%\Deployment\package.zip" -replace:match='(.*)\\output\\(.*)',replace='website' -skip:objectName=filePath,absolutePath=parameters\.xml -verbose
@ECHO %RUNCMD%
%RUNCMD%
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### PACKAGE Failed ##### && exit /B 1
@Echo INFO END PACKAGE %JOB_NAME% %TIME%
DbPack.bat
Package sql project; msbuild compiles the dcpack file and we move it to a standard location
@Echo ON
SET DBPATH=%1
Set CMD=COPY %DBPATH% "%workspace%\Deployment\"
@ECHO INFO PROCESSING: %DBPATH%
@Echo CHECK IF DB FILE EXISTS
if [%DBPATH%]==[] set DBEXISTS=false
if "%DBEXISTS%" == "false" (
@ECHO INFO NO DB PACKAGE TO COPY
) ELSE (
@ECHO INFO DB FILE IS SPECIFIED
IF EXIST %DBPATH% (
@ECHO INFO CMD= %CMD%
%CMD%
IF %ERRORLEVEL% NEQ 0 @ECHO ERROR ##### DB COPY Failed ##### && exit /B 1
)
)
@Echo INFO END DBFILE MOVE %JOB_NAME% %TIME%
VersionInfo.bat
@Echo OFF
@Echo INFO BEGIN VERSIONINFO %JOB_NAME% %TIME%
@Echo Processing: %1 %2
Set DLLVERSIONCOMMAND="C:\Program Files (x86)\Jenkins\userContent\powershell\GetDllVersion.ps1"
@ECHO PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%DLLVERSIONCOMMAND%' '%1' %2" > version.properties
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%DLLVERSIONCOMMAND%' '%1' %2" > version.properties
@Echo INFO END VERSIONINFO %JOB_NAME% %TIME%
FxCop.bat
SET FXCOPCOMMAND="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe"
SET RULESETPATH="%JENKINS_HOME%\userContent\FxCop\MinimumRecommendedRules.ruleset"
SET OUTPUTPATH="%WORKSPACE%\FxCop_results.xml"
@Echo INFO BEGIN FXCMD %JOB_NAME% %TIME%
@Echo Processing: %1
@Echo %FXCOPCOMMAND% /file:%1 /ruleset:=%RULESETPATH% /ignoregeneratedcode /forceoutput /out:%OUTPUTPATH%
%FXCOPCOMMAND% /file:%1 /ruleset:=%RULESETPATH% /ignoregeneratedcode /forceoutput /out:%OUTPUTPATH%
@Echo INFO END FXCMD %JOB_NAME% %TIME%
Test.bat
TODO: update to latest
SET MSTESTCOMMAND="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTEST.EXE"
SET CODECOVERAGETOOL="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe"
MD TestResults
@Echo %CODECOVERAGETOOL% collect /output:"TestResults\CodeCoverage.coverage" %MSTESTCOMMAND% /testcontainer:%1 %2 /nologo /resultsfile:TestResults/TestResults.trx
%CODECOVERAGETOOL% collect /output:"TestResults\CodeCoverage.coverage" %MSTESTCOMMAND% /testcontainer:%1 %2 /nologo /resultsfile:TestResults/TestResults.trx
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### TEST Failed ##### && exit /B 1
CodeCoverage.bat
@ECHO OFF
SET COVERAGECONVERTER="C:\Program Files (x86)\Jenkins\userContent\CoverageConverter\CoverageConverter.exe"
@Echo INFO BEGIN COVERAGECONVERTER %JOB_NAME% %TIME%
@Echo %COVERAGECONVERTER% %1 %2
%COVERAGECONVERTER% %1 %2
IF %ERRORLEVEL% NEQ 0 @ECHO ERROR ##### Code Coverage Failed ##### && exit /B 1
@Echo INFO END COVERAGECONVERTER %JOB_NAME% %TIME%
Documentation.bat
Set DOXYPATH="C:\Program Files\doxygen\bin\doxygen.exe"
@Echo INFO BEGIN DOCUMENTATION %JOB_NAME% %TIME%
copy "%JENKINS_HOME%\userContent\Doxyfile.txt" "%WORKSPACE%"
@Echo PROJECT_NAME=%JOB_NAME% >>"%WORKSPACE%"\Doxyfile.txt
%DOXYPATH% "%WORKSPACE%"\Doxyfile.txt
IF %ERRORLEVEL% NEQ 0 echo ERROR ##### DOCUMENTATION Failed ##### && exit /B 1
@Echo INFO END DOCUMENTATION %JOB_NAME% %TIME%