-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
138 lines (122 loc) · 4.83 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
#------------------------------- GLOBAL DEFAULTS ------------------------------
default:
id_tokens:
ID_TOKEN:
aud: https://vault.dracoon.net
#------------------------------ VARIABLES -----------------------------
variables:
DISABLE_QUALITY_GATES: 'false'
#------------------------------ TEMPLATES -----------------------------
.secrets-template: &secrets-template
secrets:
ARTIFACTORY_REPO:
vault: Artifactory/repo-dracoon-sdk-crypto-csharp@Build-Environment
file: false
SONAR_TOKEN:
vault: Sonar/token@Build-Environment
file: false
SONAR_URL:
vault: Sonar/url@Build-Environment
file: false
NUGET_ACCESS_KEY:
vault: nuget/access-key@Build-Environment
file: false
#------------------------------- PREPARE ------------------------------
prepare:
stage: .pre
tags:
- windows-amd64
script:
- nuget locals all -clear
#
# extract project version
- $VERSION_LINE = $(get-content -Path .\DracoonCryptoSdk\DracoonCryptoSdk.csproj | Select-String -Pattern '<Version>').ToString()
- $VERSION = $VERSION_LINE.SubString($VERSION_LINE.IndexOf("<Version>") + 9, $VERSION_LINE.IndexOf("</Version>") - $VERSION_LINE.IndexOf("<Version>") - 9)
- echo "$VERSION" >> shared.txt
artifacts:
expire_in: 1 week
paths:
- .\shared.txt
#-------------------------------- BUILD -------------------------------
build:
stage: build
tags:
- windows-amd64
before_script:
- mkdir .\dist
script:
- nuget restore .\DracoonCryptoSdk\DracoonCryptoSdk.csproj -Source https://api.nuget.org/v3/index.json
- dotnet pack -c Release .\DracoonCryptoSdk\DracoonCryptoSdk.csproj -o .\dist
artifacts:
expire_in: 1 week
paths:
- .\dist
#-------------------------------- TEST --------------------------------
unit-test:
stage: test
tags:
- windows-amd64
script:
- nuget restore .\DracoonCryptoSdkTest\DracoonCryptoSdkTest.csproj -Source https://api.nuget.org/v3/index.json
- dotnet test -c Release .\DracoonCryptoSdkTest\DracoonCryptoSdkTest.csproj
sonar:
stage: test
<<: *secrets-template
rules:
- if: $DISABLE_QUALITY_GATES == "false"
allow_failure: false
when: on_success
- if: $DISABLE_QUALITY_GATES == "true"
allow_failure: true
when: on_success
tags:
- windows-amd64
dependencies:
- prepare
before_script:
- $VERSION = (GET-CONTENT ./shared.txt)
- $BASE_DIR=(Get-Location).path
script:
- nuget restore .\DracoonCryptoSdk\DracoonCryptoSdk.csproj -Source https://api.nuget.org/v3/index.json
- nuget restore .\DracoonCryptoSdkTest\DracoonCryptoSdkTest.csproj -Source https://api.nuget.org/v3/index.json
- dotnet build -c Release .\DracoonCryptoSdkTest\DracoonCryptoSdkTest.csproj
- C:\BuildTools\dependency-check\bin\dependency-check.bat --scan .\DracoonCryptoSdk --project dracoon-crypto-sdk-csharp --format ALL
- C:\BuildTools\dotCover\dotCover.exe cover /TargetExecutable="C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" /TargetArguments="Dracoon.Crypto.Sdk.Test.dll" /TargetWorkingDir="DracoonCryptoSdkTest\bin\Release\net8.0" /Scope="Dracoon.Crypto.Sdk.dll" /Filters="-:module=Dracoon.Crypto.Sdk.Example;-:module=Dracoon.Crypto.Sdk.Test" /Output=".\dotCoverResult.html" /ReportType="HTML"
- dotnet clean -c Release .\DracoonCryptoSdkSolution.sln
- C:\ProgramData\chocolatey\lib\sonarscanner-msbuild-net46\tools\SonarScanner.MSBuild.exe begin /s:${BASE_DIR}\SonarQube.Analysis.xml /k:dracoon-crypto-sdk-csharp /v:${VERSION} /d:sonar.host.url=$SONAR_URL /d:sonar.login=$SONAR_TOKEN /d:sonar.branch.name="${CI_COMMIT_REF_SLUG}" /d:sonar.scm.revision=${CI_COMMIT_SHORT_SHA}
- dotnet build -c Release .\DracoonCryptoSdk\DracoonCryptoSdk.csproj
- C:\ProgramData\chocolatey\lib\sonarscanner-msbuild-net46\tools\SonarScanner.MSBuild.exe end /d:sonar.login=$SONAR_TOKEN
#-------------------------------- DEPLOY ------------------------------
deploy-to-artifactory:
stage: deploy
<<: *secrets-template
rules:
- when: manual
allow_failure: true
tags:
- windows-amd64
dependencies:
- build
script:
- jf rt u --flat=true "dist\*.nupkg" $ARTIFACTORY_REPO
deploy-to-nuget:
stage: deploy
<<: *secrets-template
rules:
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
- when: never
tags:
- windows-amd64
dependencies:
- build
script:
- dotnet nuget push .\dist\*.nupkg -k $NUGET_ACCESS_KEY -s https://www.nuget.org/api/v2/package