ci example:
variables:
MS_BUILD: "[MSBUILD_PATH]"
PYTHON: "[PYTHON_PATH]"
VS_TEST_TOOLS: "[VS_TEST_TOOLS_PATH]"
SONAR_TOKEN: $SONAR_TOKEN
SONAR_HOST_URL: $SONAR_HOST_URL
stages:
- RELEASE_VERSION_INFO
- VERSION_INFO
- BUILD
- SCAN
BUILD_JOB:
artifacts:
paths:
- bin/Release/*.dll
- bin/Release/*.exe
dependencies:
- VERSION_INFO_JOB
script:
- Invoke-Expression "& `[MS_BUILD]` /nologo /noautoresponse /p:Configuration=Release /p:platform=Win32 /p:TreatWarningsAsErrors=true /flp:PerformanceSummary``;Summary``;logfile=msbuild.release.log``;encoding=UTF-8 proj_XXX_XXXXXX/proj_XXX_XXXXXX.sln"
- if($LASTEXITCODE) { exit $LASTEXITCODE }
- Copy-Item bin/Release/XXX_XXXXXX.exe -Destination bin
- exit $LASTEXITCODE
stage: BUILD
tags: [windows]
RELEASE_VERSION_INFO_JOB:
artifacts:
paths:
- proj_XXX_XXXXXX/resource.h
only:
- /^hotfix.*$/
- /^release.*$/
script:
- $file = "proj_XXX_XXXXXX/resource.h"
- $regex = "//#define _CI_BUILD_RELEASE$"
- $replace = "#define _CI_BUILD_RELEASE"
- (Get-Content $file) -replace $regex, $replace | Set-Content $file
stage: RELEASE_VERSION_INFO
tags: [windows]
VERSION_INFO_JOB:
artifacts:
paths:
- proj_XXX_XXXXXX/resource.h
dependencies:
- RELEASE_VERSION_INFO_JOB
script:
- $file = "proj_XXX_XXXXXX/resource.h"
- $regex = "//#define _CI_BUILD$"
- $replace = "#define _CI_BUILD"
- (Get-Content $file) -replace $regex, $replace | Set-Content $file
- $regex = "#define _CI_BUILD_NUMBER[^\n]*"
- $replace = "#define _CI_BUILD_NUMBER ${env:CI_PIPELINE_ID}"
- (Get-Content $file) -replace $regex, $replace | Set-Content $file
- $regex = "#define _CI_BUILD_URL[^\n]*"
- $replace = "#define _CI_BUILD_URL `"${env:CI_PROJECT_URL}/pipelines/${env:CI_PIPELINE_ID}`""
- (Get-Content $file) -replace $regex, $replace | Set-Content $file
- $LAST_COMMIT_CHANGE_SET = & git diff-tree --no-commit-id --name-only -r HEAD
- $LAST_COMMIT_CHANGE_SET = $LAST_COMMIT_CHANGE_SET -join "\n| "
- $regex = "#define _COMMIT_CHANGE_SET[^\n]*"
- $replace = "#define _COMMIT_CHANGE_SET `"$LAST_COMMIT_CHANGE_SET`""
- (Get-Content $file) -replace $regex, $replace | Set-Content $file
- $regex = "#define _COMMIT_BRANCH_NAME[^\n]*"
- $replace = "#define _COMMIT_BRANCH_NAME `"${env:CI_COMMIT_REF_NAME}`""
- (Get-Content