1
|
#CI_COMMIT_MESSAGE is header and description
|
2
|
#Only childs are ANDed and child restrictions are ORed
|
3
|
variables:
|
4
|
NUGET_PATH: "C:\\Tools\\Nuget\\nuget.exe"
|
5
|
MSBUILD_PATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
|
6
|
VSTEST_PATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe"
|
7
|
RELEASE_FOLDER: "C:\\Users\\cztestman01\\OneDrive - Leuze electronic GmbH + Co. KG\\00_BUILDS\\DummyProject"
|
8
|
stages:
|
9
|
- build
|
10
|
- test
|
11
|
- release
|
12
|
before_script:
|
13
|
- 'echo "Execution time" (Get-Date).ToString("yyyy_MM_dd-HH_mm_ss")' # Current time
|
14
|
- 'cd .\DummyProject' #Change directory to lowest same working directory
|
15
|
- '& "$NUGET_PATH" restore' #Before all restore packages
|
16
|
#Job for building
|
17
|
build_job:
|
18
|
stage: build
|
19
|
tags:
|
20
|
- csharp
|
21
|
- win10
|
22
|
only:
|
23
|
refs:
|
24
|
- branches
|
25
|
variables:
|
26
|
- $CI_COMMIT_MESSAGE =~ /@test/i #manual trigger for testing
|
27
|
- $CI_COMMIT_MESSAGE =~ /@deploy/i #manual trigger for deploy
|
28
|
- $CI_COMMIT_MESSAGE =~ /See merge request/ #auto trigger for merge requests from GitLab
|
29
|
- $CI_COMMIT_MESSAGE =~ /merge branch/i #auto trigger for merge requests from command
|
30
|
- $CI_COMMIT_MESSAGE =~ /Merge remote-tracking branch/i #auto trigger for remote merge requests from command
|
31
|
script:
|
32
|
- '& "$MSBUILD_PATH" /p:Platform=x64' #Build project
|
33
|
- '& "$MSBUILD_PATH" /p:Configuration="Release" /p:Platform=x64' #Build project
|
34
|
artifacts:
|
35
|
expire_in: 2 days
|
36
|
paths:
|
37
|
- '.\DummyProject\DummyProject\bin\' #Upload all builds as artifact
|
38
|
- '.\DummyProject\CalcTests\bin\' #Upload all builds as artifact
|
39
|
#Job for testing
|
40
|
test_job:
|
41
|
stage: test
|
42
|
tags:
|
43
|
- csharp
|
44
|
- win10
|
45
|
only:
|
46
|
refs:
|
47
|
- branches
|
48
|
variables:
|
49
|
- $CI_COMMIT_MESSAGE =~ /@testApp/i #manual trigger for testing
|
50
|
- $CI_COMMIT_MESSAGE =~ /@deploy/i #manual trigger for deploy
|
51
|
- $CI_COMMIT_MESSAGE =~ /@testFull/i #manual trigger for testing full
|
52
|
- $CI_COMMIT_MESSAGE =~ /See merge request/ #auto trigger for merge requests from GitLab
|
53
|
- $CI_COMMIT_MESSAGE =~ /merge branch/i #auto trigger for merge requests from command
|
54
|
- $CI_COMMIT_MESSAGE =~ /Merge remote-tracking branch/i #auto trigger for remote merge requests from command
|
55
|
script:
|
56
|
- '& "$VSTEST_PATH" .\CalcTests\bin\x64\Release\CalcTests.dll' #Run tests using console mode of MSTest (Unit)
|
57
|
dependencies:
|
58
|
- build_job
|
59
|
#Job for release public
|
60
|
release_public_job:
|
61
|
stage: release
|
62
|
tags:
|
63
|
- csharp
|
64
|
- win10
|
65
|
only:
|
66
|
refs:
|
67
|
- master
|
68
|
variables:
|
69
|
- $CI_COMMIT_MESSAGE =~ /@deploy/i #manual trigger for testing
|
70
|
- $CI_COMMIT_MESSAGE =~ /See merge request/ #auto trigger for merge requests from GitLab
|
71
|
- $CI_COMMIT_MESSAGE =~ /merge branch/i #auto trigger for merge requests from command
|
72
|
- $CI_COMMIT_MESSAGE =~ /Merge remote-tracking branch/i #auto trigger for remote merge requests from command
|
73
|
script:
|
74
|
- '$today = (Get-Date).ToString("yyyy_MM_dd-HH_mm_ss")'
|
75
|
- '& mkdir "$RELEASE_FOLDER\$today"'
|
76
|
- '& echo "Build branch: $CI_COMMIT_BRANCH`n" > $RELEASE_FOLDER\$today\buildLog.txt'
|
77
|
- '& echo "Pipeline: $CI_PIPELINE_URL`n" >> $RELEASE_FOLDER\$today\buildLog.txt'
|
78
|
- '& echo "Pipeline trigger source: $CI_PIPELINE_SOURCE`n" >> $RELEASE_FOLDER\$today\buildLog.txt'
|
79
|
- '& echo "Runner: $CI_RUNNER_DESCRIPTION`n" >> $RELEASE_FOLDER\$today\buildLog.txt'
|
80
|
- '& echo "Description: $CI_COMMIT_MESSAGE`n" >> $RELEASE_FOLDER\$today\buildLog.txt'
|
81
|
- '& xcopy /y /s ".\DummyProject\bin\*.*" "$RELEASE_FOLDER\$today"'
|
82
|
artifacts:
|
83
|
name: "Deploy artifact"
|
84
|
expire_in: 30 days
|
85
|
paths:
|
86
|
- '.\DummyProject\DummyProject\bin\'
|
87
|
dependencies:
|
88
|
- build_job #Build must be ok and using this, artifacts will be used
|
89
|
- test_job #Only when tests are OK
|