-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
130 lines (113 loc) · 4.02 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
stages:
- prebuild
- build:rpm
- build:richaclrpm
- publish_rpm
before_script:
- export RICHACL_BUILD_ID=${CI_PIPELINE_ID}git${CI_COMMIT_SHA:0:8}
- echo "Exporting RICHACL_BUILD_ID=${RICHACL_BUILD_ID}"
- test -n "${CI_COMMIT_TAG}" && export TAG_MAJOR=$(echo ${CI_COMMIT_TAG} | sed -e 's/^v//;s/\([^_]\+\)_\([^_]\+\)_.*/\1.\2/')
- test -n "${CI_COMMIT_TAG}" && export TAG_MINOR=$(echo ${CI_COMMIT_TAG} | sed -e 's/^v//;s/\([^_]\+\)_\([^_]\+\)_//;s/_/./')
variables:
SAMBAVERSION: "4.13.5" # latest is 4.13.7 but we have a missing dependency, which would require bringing in python 3.8
## Pre-builds ##
# Use the docker image coming out from this stage as an input base image for the build stages
.prebuid-template: &prebuild-template_definition
stage: prebuild
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- export DESTINATION="gitlab-registry.cern.ch/dss/samba-richacl/prebuild-${PREBUILD_NAME}"
- export DOCKERFILE="$CI_PROJECT_DIR/gitlab-ci/prebuild-${PREBUILD_NAME}.Dockerfile"
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD | base64)\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --cache="false" --destination $DESTINATION --dockerfile $DOCKERFILE --context $CI_PROJECT_DIR
only:
variables:
- $PREBUILD_TRIGGER
prebuild-c8:
<<: *prebuild-template_definition
variables:
PREBUILD_NAME: c8
## Builds ##
# SRPM and RPM
samba_rpm:
stage: build:rpm
image: gitlab-registry.cern.ch/dss/samba-richacl/prebuild-c8
script:
- if [ -z "${CI_COMMIT_TAG}" ]; then echo "This is not a tagged commit, forcing version to $SAMBAVERSION"; else export SAMBAVERSION=${CI_COMMIT_TAG}; echo "Building $SAMBAVERSION"; fi
- if [ -d cache/samba-$SAMBAVERSION ]; then echo "Found cache, skipping build"; exit 0; fi
- mkdir -p ~/rpmbuild/{SOURCES,SPECS} RPMS
- bash -x ./samba_richacl_build.sh samba-$SAMBAVERSION tgz
- rpmbuild -bb ~/rpmbuild/SPECS/samba.spec
- cp ~/rpmbuild/SRPMS/*.src.rpm ~/rpmbuild/RPMS/x86_64/*rpm ~/rpmbuild/RPMS/noarch/*rpm RPMS
- cp -r ~/rpmbuild/BUILD/* cache/
- ls -l cache/
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- cache/
artifacts:
expire_in: 7 days
paths:
- RPMS
tags:
- docker_node
richacl_rpm:
stage: build:richaclrpm
image: gitlab-registry.cern.ch/dss/samba-richacl/prebuild-c8
script:
- if [ -z "${CI_COMMIT_TAG}" ]; then echo "This is not a tagged commit, forcing version to $SAMBAVERSION"; else export SAMBAVERSION=${CI_COMMIT_TAG}; echo "Building RichACL for $SAMBAVERSION"; fi
- if ! [ -d cache/samba-$SAMBAVERSION ]; then echo "Invalid cache"; ls -l cache/; exit -1; fi
- mkdir -p ~/rpmbuild/{SOURCES,SPECS,BUILD} RPMS
- cp -r cache/samba-$SAMBAVERSION ~/rpmbuild/BUILD/
- bash -x ./samba_richacl_build.sh samba-$SAMBAVERSION srpm
- rpmbuild -bb --define "smbversion $SAMBAVERSION" ~/rpmbuild/SPECS/samba_richacl.spec
- cp ~/rpmbuild/SRPMS/samba_richacl*.src.rpm ~/rpmbuild/RPMS/x86_64/samba_richacl*rpm RPMS
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- cache/
artifacts:
expire_in: 7 days
paths:
- RPMS
tags:
- docker_node
dependencies:
- samba_rpm
# manual cache cleanup (not necessary in normal conditions)
clean_cache:
when: manual
stage: .post
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
script:
- ls -l cache/
- rm -rf cache/*
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- cache/
tags:
- docker_node
## Publishing, only for tagged builds ##
publish_tagged_rpm:
stage: publish_rpm
only:
- tags
except:
- schedules
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
script:
- if [ -z "${CI_COMMIT_TAG}" ]; then echo "This is not a tagged commit, exiting"; exit 0; fi
- yum install -y sudo sssd-client createrepo
- sudo -u stci -H ./gitlab-ci/publish_rpms.sh
artifacts:
expire_in: 7 days
paths:
- RPMS
tags:
- docker_node
dependencies:
- samba_rpm
- richacl_rpm