-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
144 lines (126 loc) · 5.99 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
139
140
141
142
143
variables:
CI_DEBUG_TRACE:
value: ''
description: "Verbose output of all of GitLab's output, including git cloning information. More info: https://docs.gitlab.com/ee/ci/variables/#enable-debug-logging"
CI_SCRIPT_TRACE:
value: 'false'
description: "Verbose output of CI script."
CI_GITVERSION_TRACE:
value: 'true'
description: "Gitversion config emited and verbosity set. Default to true in the Guided Exploration for learning purposes."
SECURE_LOG_LEVEL:
value: ''
description: "Set to one of: 'fatal,warn,error,info,debug' More info: https://docs.gitlab.com/ee/user/application_security/sast/#logging-level"
TRACE:
value: ''
description: "Set to 1 to output helm trace commands. More Info: https://docs.gitlab.com/ee/topics/autodevops/customize.html#cicd-variables"
PACKAGENAME: $CI_PROJECT_NAME
#https://docs.gitlab.com/ee/topics/git/useful_git_commands.html#debugging-with-git-embedded-traces
GIT_CURL_VERBOSE:
value: ''
description: 'Set to 1 to enable tracing of git https operations. More info: https://docs.gitlab.com/ee/topics/git/useful_git_commands.html#debugging-with-git-embedded-traces'
GIT_TRACE_PERFORMANCE:
value: ''
description: 'Set to 1 to enable tracing of performance data, showing how long each particular git invocation takes More info: https://docs.gitlab.com/ee/topics/git/useful_git_commands.html#debugging-with-git-embedded-traces'
GIT_TRACE_SETUP:
value: ''
description: 'Set to 1 to enable tracing of what git is discovering about the repository and environment it’s interacting with. More info: https://docs.gitlab.com/ee/topics/git/useful_git_commands.html#debugging-with-git-embedded-traces'
GIT_TRACE_PACKET:
value: ''
description: 'Set to 1 to enable tracing packet-level tracing for network operations. More info: https://docs.gitlab.com/ee/topics/git/useful_git_commands.html#debugging-with-git-embedded-traces'
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
SAST_JAVA_VERSION: 17
stages:
- .pre
- build
- release
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_BRANCH
when: always
include:
- local: '/gitversion-ci-cd-plugin-extension.gitlab-ci.yml'
determineversion:
extends: .gitversion_function
cache:
paths:
- ".m2/repository"
keycloak-login-theme:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:latest
stage: build
script:
- apt-get update
- apt-get install curl unzip openjdk-17-jdk maven -y
- npm i
- npm run build-keycloak-theme
- ls -al ./build_keycloak
- ls -al ./build_keycloak/target/
artifacts:
paths:
- ./build_keycloak/src/main/resources/theme/
- ./build_keycloak/target/*
docker-package:
stage: build
image: docker:latest
needs:
- keycloak-login-theme
dependencies:
- keycloak-login-theme
services:
- docker:dind
script:
- |
ls -al
ls -al build_keycloak
ls -al build_keycloak/target
if [[ "${CI_SCRIPT_TRACE}" == "true" ]] || [[ -n "${CI_DEBUG_TRACE}" ]]; then
echo "Debugging enabled"
set -xv
fi
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
#Build date for opencontainers
BUILDDATE="'$(date '+%FT%T%z' | sed -E -n 's/(\+[0-9]{2})([0-9]{2})$/\1:\2/p')'" #rfc 3339 date
IMAGE_LABELS="$IMAGE_LABELS --label org.opencontainers.image.created=$BUILDDATE --label build-date=$BUILDDATE"
#Description for opencontainers
BUILDTITLE=$(echo $CI_PROJECT_TITLE | tr " " "_")
IMAGE_LABELS="$IMAGE_LABELS --label org.opencontainers.image.title=$BUILDTITLE --label org.opencontainers.image.description=$BUILDTITLE"
#Add ref.name for opencontainers
IMAGE_LABELS="$IMAGE_LABELS --label org.opencontainers.image.ref.name=$CI_REGISTRY_IMAGE:$(echo $CI_COMMIT_REF_NAME | tr / _)"
#Build Version Label and Tag from git tag, LastVersionTagInGit was placed by a previous job artifact
IMAGE_LABELS="$IMAGE_LABELS --label org.opencontainers.image.version=$GitVersion_LegacySemVer"
ADDITIONALTAGLIST="$ADDITIONALTAGLIST $GitVersion_LegacySemVer"
ADDITIONALTAGLIST="$ADDITIONALTAGLIST $(echo $CI_COMMIT_REF_NAME | tr / _) $CI_COMMIT_SHORT_SHA"
if [[ "$CI_COMMIT_REF_NAME" == "main" ]]; then ADDITIONALTAGLIST="$ADDITIONALTAGLIST latest"; fi
if [[ -n "$ADDITIONALTAGLIST" ]]; then
for TAG in $ADDITIONALTAGLIST; do
FORMATTEDTAGLIST="${FORMATTEDTAGLIST} --tag $CI_REGISTRY_IMAGE:$TAG ";
done;
fi
echo $FORMATTEDTAGLIST
echo $IMAGE_LABELS
docker build $IMAGE_LABELS --pull $FORMATTEDTAGLIST -f Dockerfile .
if [[ $CI_COMMIT_REF_PROTECTED == "false" ]]; then
echo "To prevent clutter, containers are not pushed or download tested unless the branch is protected."
else
echo "Pushing container to registry."
if [[ -n "$ADDITIONALTAGLIST" ]]; then
for TAG in $ADDITIONALTAGLIST; do
docker push "$CI_REGISTRY_IMAGE:$TAG"
echo "Image can be pulled with the reference: $CI_REGISTRY_IMAGE:$TAG"
done;
fi
fi
# Please see [Release CI/CD examples](https://docs.gitlab.com/ee/user/project/releases/release_cicd_examples.html) for many rich examples for triggering a release only on specific conditions.
do_gitlab_release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli
rules:
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED != "false"'
#This last rule will do a release for any protected branch. Literal branch names can be used if desired.
script:
- >
release-cli create --name ${GitVersion_LegacySemVer} --description $CI_COMMIT_REF_NAME-$CI_JOB_ID
--tag-name ${GitVersion_LegacySemVer} --ref $CI_COMMIT_SHA
--assets-link "{\"name\":\"Packaged Artifact\",\"url\":\"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGENAME}/${GitVersion_LegacySemVer}/${PACKAGENAME}.${GitVersion_LegacySemVer}.tar.gz\"}"