-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
71 lines (63 loc) · 2.12 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
image: laszlo/containerruntimeglobal-build-slim:latest
variables:
OBJECTS_DIRECTORY: obj
NUGET_PACKAGES_DIRECTORY: .nuget
SOURCE_CODE_PATH: LibPing.Net
cache:
key: $CI_JOB_STAGE-$CI_COMMIT_REF_SLUG
paths:
- $SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/project.assets.json
- $SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/*.csproj.nuget.*
- $NUGET_PACKAGES_DIRECTORY
policy: pull-push
before_script:
- dotnet restore --packages $NUGET_PACKAGES_DIRECTORY
build:
stage: build
script:
- dotnet build --no-restore
tests:
stage: test
script:
- dotnet test --no-restore
securityanalysis:
stage: test
script:
- 'dotnet tool install --global security-scan'
- security-scan ./LibPing.Net.sln
codeanalysis:
stage: test
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
only:
- merge_requests
- main
- develop
script:
- "apt-get update"
- "apt-get install -y openjdk-11-jre"
- "java --version"
- "dotnet tool install --global dotnet-sonarscanner"
- "dotnet sonarscanner begin /k:\"$SONAR_PROJECT_KEY\" /d:sonar.cs.opencover.reportsPaths=\".coverlet/coverage.opencover.xml\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" /o:\"$SONAR_ORGANIZATION\" "
- "dotnet build"
- "dotnet test LibPing.Net.Test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=\"../.coverlet/\""
- "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
allow_failure: true
deploy:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
when: never
stage: deploy
variables:
DOCKER_HOST: tcp://172.17.0.1:2375
script:
- dotnet build -c Release --no-restore
- dotnet pack LibPing.Net/LibPing.Net.csproj -c Release --no-restore -o .
- dotnet nuget push "*.nupkg" --skip-duplicate -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json