forked from cern-fts/fts3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
131 lines (114 loc) · 3.56 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
stages:
- build
- docker
- test
- publish
#--------------------------
# Build templates
#--------------------------
.build-template: &build-template_definition
stage: build
script:
- ci/fedora-packages.sh
- ci/common-rpm-build.sh
- mkdir ${CI_JOB_NAME}
- cp -rv build/RPMS build/SRPMS ${CI_JOB_NAME}
- tree ${CI_JOB_NAME}
variables:
BRANCH: ${CI_COMMIT_REF_NAME}
artifacts:
paths:
- "$CI_JOB_NAME"
#--------------------------
# Build jobs
#--------------------------
cc7:
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
<<: *build-template_definition
#--------------------------
# Docker build templates
#--------------------------
.kaniko_build: &kaniko_build-template
stage: docker
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- if [[ -z "$CI_COMMIT_TAG" ]];
then CACHE="true"; REGISTRY="latest";
else CACHE="false"; REGISTRY="${CI_COMMIT_TAG}";
fi
- if [[ -z "$DMC_REPO" ]];
then DMC_REPO="https://dmc-repo.web.cern.ch/dmc-repo/dmc-devel-el7.repo";
fi
- DESTINATION="gitlab-registry.cern.ch/fts/fts3:${REGISTRY}"
- printf "CACHE=${CACHE}\nDESTINATION=${DESTINATION}\nDMCREPO=${DMC_REPO}\n"
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --dockerfile ci/docker/Dockerfile-ci --context "${CI_PROJECT_DIR}" --cache=${CACHE} --destination ${DESTINATION} --build-arg dmcrepo=${DMC_REPO}
retry: 1
#--------------------------
# Docker build jobs
#--------------------------
docker_build:
<<: *kaniko_build-template
needs:
- job: cc7
rules:
- if: $CI_COMMIT_REF_NAME == "develop"
docker_tag:
<<: *kaniko_build-template
variables:
DMC_REPO: https://dmc-repo.web.cern.ch/dmc-repo/dmc-rc-el7.repo
needs:
- job: cc7
rules:
- if: $CI_COMMIT_TAG != null
#--------------------------
# Testing templates
#--------------------------
.test-template: &test-template_definition
stage: test
script:
- yum install -y git createrepo
- ci/write-repo-file.sh
- mkdir -p /repo/fts ; cp -v cc7/RPMS/*/*.rpm /repo/fts ; createrepo /repo/fts
- echo -e "[fts]\nname=FTS\nbaseurl=file:///repo/fts\ngpgcheck=0\nenabled=1\npriority=2" > /etc/yum.repos.d/fts.repo
- yum install -y fts-tests
- fts-unit-tests --log_level=all --report_level=detailed
#--------------------------
# Testing jobs
#--------------------------
cc7-test:
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
needs:
- job: cc7
<<: *test-template_definition
#--------------------------
# Publish templates
#--------------------------
.publish-template: &publish-template_definition
stage: publish
image: gitlab-registry.cern.ch/eos/gitlab-eos/alma9:latest
dependencies:
- cc7
script:
- automount
- cat "$repo_passwd" | kinit "$repo_user"
- packaging/fts-repo-manager.py --action add --base /eos/workspace/f/fts/repo/www/repos/ --ref ${CI_COMMIT_REF_NAME} --packages cc7/RPMS/*/*.rpm cc7/SRPMS/*
tags:
- docker-privileged-xl
retry: 2
#--------------------------
# Publish jobs
#--------------------------
rpms:
<<: *publish-template_definition
rules:
- if: '$CI_PROJECT_NAMESPACE != "fts"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_TAG != null'
- if: '$CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_TAG == null'
when: manual