-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
92 lines (82 loc) · 2.87 KB
/
.gitlab-ci.yml
File metadata and controls
92 lines (82 loc) · 2.87 KB
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
variables:
# 1) Name of directory where restore and build objects are stored.
OBJECTS_DIRECTORY: 'obj'
# 2) Name of directory used for keeping restored dependencies.
NUGET_PACKAGES_DIRECTORY: '.nuget'
# 3) A relative path to the source code from project repository root.
# NOTE: Please edit this path so it matches the structure of your project!
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_ARGS: >
-p:ContinuousIntegrationBuild=true
-p:Deterministic=true
cache:
# Per-stage and per-branch caching.
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
paths:
# Specify three paths that should be cached:
#
# 1) Main JSON file holding information about package dependency tree, packages versions,
# frameworks etc. It also holds information where to the dependencies were restored.
- '$OBJECTS_DIRECTORY/project.assets.json'
- '$OBJECTS_DIRECTORY/project.assets.json'
# 2) Other NuGet and MSBuild related files. Also needed.
- '$OBJECTS_DIRECTORY/*.csproj.nuget.*'
- '$OBJECTS_DIRECTORY/*.csproj.nuget.*'
# 3) Path to the directory where restored dependencies are kept.
- '$NUGET_PACKAGES_DIRECTORY'
#
# 'pull-push' policy means that latest cache will be downloaded (if it exists)
# before executing the job, and a newer version will be uploaded afterwards.
# Such a setting saves time when there are no changes in referenced third-party
# packages.
#
# For example, if you run a pipeline with changes in your code,
# but with no changes within third-party packages which your project is using,
# then project restore will happen quickly as all required dependencies
# will already be there — unzipped from cache.
# 'pull-push' policy is the default cache policy, you do not have to specify it explicitly.
policy: pull-push
stages:
- build
- lint
- build-docker
build:
stage: build
image: mcr.microsoft.com/dotnet/sdk:7.0
script: |
echo "Building the project..."
dotnet restore ${DOTNET_ARGS}
dotnet build ${DOTNET_ARGS}
artifacts:
paths:
- $bin/Debug/net7.0/
lint:
stage: lint
image: mcr.microsoft.com/dotnet/sdk:7.0
script: |
echo "Checking Code-style..."
dotnet tool restore
dotnet tool install -g roslynator.dotnet.cli --version 0.6.0
/root/.dotnet/tools/roslynator analyze
dependencies:
- build
build-docker:
variables:
KANIKO_ARGS: ""
KANIKO_BUILD_CONTEXT: $CI_PROJECT_DIR
stage: build-docker
image:
name: gcr.io/kaniko-project/executor:v1.10.0-debug
entrypoint: [""]
rules:
- if: $CI_COMMIT_TAG
script: |
mkdir -p /kaniko/.docker
DOCKERFILE_PATH=${DOCKERFILE_PATH:-"$KANIKO_BUILD_CONTEXT/Dockerfile"}
/kaniko/executor \
--context $KANIKO_BUILD_CONTEXT \
--dockerfile $DOCKERFILE_PATH \
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG \
$KANIKO_ARGS \
--destination $CI_REGISTRY_IMAGE:latest