-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
159 lines (141 loc) · 7.09 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
144
145
146
147
148
149
150
151
152
153
154
155
156
stages:
- Artifacts
- Cross-Project
- End-to-End
- Dashboard-Update
before_script:
- export BASE_URL=${BASE_URL:-$(echo $CI_PROJECT_URL | cut -d'/' -f1-3)}
- export CI_COMMIT_SHA_SHORT=$(echo ${CI_COMMIT_SHA} | cut -c -8)
- mkdir -p ./data ; touch ./data/empty.env
- for envfile in data/*env ; do source $envfile ; echo ----- $envfile ---- ; cat $envfile ; done
- >
if [ -z "$CROSS_CLOUD_YML" ]; then
export CROSS_CLOUD_YML="https://raw.githubusercontent.com/CrossCloudCI/cncf-configuration/production/cross-cloud.yml"
else
export CROSS_CLOUD_YML="$CROSS_CLOUD_YML"
fi
- source /opt/local/etc/rvmrc ; source /opt/local/etc/profile.d/rvm.sh ; cp -a /opt/local/dashboard /dashboard ; pushd /dashboard ; source /opt/local/.env ; ./bin/update_dashboard ; popd
.build_source: &build_source
image: buildpack-deps:stretch
stage: Artifacts
variables:
# SOURCE
# ORG: MUST BE SET
# PROJECT: MUST BE SET
# PROJECT_ID: MUST BE SET
script:
- apt update && apt -y install jq
- >
if [ -z "$SOURCE" ]; then
exit 0 #Should Show Skipped on Gitlab CI FIXME
elif [ "$DISABLE_SOURCE" == "yes" ]; then
exit 0 #Should Show Skipped on Gitlab CI FIXME
elif [ "$ARCH" == "arm64" ] && [ "$TARGET_PROJECT_NAME" == "envoy" ]; then
PROJECT_JOB=$(curl --header "PRIVATE-TOKEN:${TOKEN}" "${BASE_URL}/api/v4/projects/$PROJECT_ID/pipelines/${SOURCE}/jobs?scope=success" | jq '.[] | select(.name=="container-arm") | .id')
curl -s -o data/"$TARGET_PROJECT_NAME".env -L "${BASE_URL}/${ORG}/${TARGET_PROJECT_NAME}/-/jobs/${PROJECT_JOB}/artifacts/raw/release.env"
cat data/"$TARGET_PROJECT_NAME".env
elif [ "$ARCH" == "arm64" ] && [ "$TARGET_PROJECT_NAME" == "fluentd" ]; then
PROJECT_JOB=$(curl --header "PRIVATE-TOKEN:${TOKEN}" "${BASE_URL}/api/v4/projects/$PROJECT_ID/pipelines/${SOURCE}/jobs?scope=success" | jq '.[] | select(.name=="container-arm") | .id')
curl -s -o data/"$TARGET_PROJECT_NAME".env -L "${BASE_URL}/${ORG}/${TARGET_PROJECT_NAME}/-/jobs/${PROJECT_JOB}/artifacts/raw/release.env"
cat data/"$TARGET_PROJECT_NAME".env
else
PROJECT_JOB=$(curl --header "PRIVATE-TOKEN:${TOKEN}" "${BASE_URL}/api/v4/projects/$PROJECT_ID/pipelines/${SOURCE}/jobs?scope=success" | jq '.[] | select(.name=="container") | .id')
curl -s -o data/"$TARGET_PROJECT_NAME".env -L "${BASE_URL}/${ORG}/${TARGET_PROJECT_NAME}/-/jobs/${PROJECT_JOB}/artifacts/raw/release.env"
cat data/"$TARGET_PROJECT_NAME".env
fi
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
untracked: true
expire_in: 5 weeks
paths:
- ./data
.cross-project: &cross-project
image: crosscloudci/debian-helm-kubectl:v3.2.4-v1.18.4
stage: Cross-Project
script:
- echo "$KUBECONFIG" | base64 -d | tee ./kubeconfig >/dev/null
- export KUBECONFIG=$(pwd)/kubeconfig
- kubectl get nodes
- kubectl get componentstatuses
- env | grep IMAGE
- env | grep TAG
- echo Removing any previous deploys of "${DEPLOYMENT_NAME}"
- helm list --filter "${DEPLOYMENT_NAME}" > /dev/null && helm delete "${DEPLOYMENT_NAME}" || true
- helm repo add stable http://cncf.gitlab.io/stable
- helm repo update
- >
if [ "$TARGET_PROJECT_NAME" == so ]; then
helm repo add onap-amsterdam https://cncf.gitlab.io/onap-amsterdam
helm repo add onap-master https://cncf.gitlab.io/onap-master
# echo "Remove old deploys"
# helm delete --purge onap-config || true
# helm delete --purge onap-log || true
# helm delete --purge onap-robot || true
# sleep 10
echo "Create project namespaces"
kubectl create namespace onap || true
kubectl create namespace onap-log || true
kubectl create namespace onap-mso || true
kubectl create namespace onap-robot || true
kubectl create secret docker-registry onap-docker-registry-key --docker-server=nexus3.onap.org:10001 --docker-username="$ONAP_USERNAME" --docker-password="$ONAP_PASSWORD" --docker-email="$ONAP_EMAIL" --namespace=onap || true
kubectl create secret docker-registry onap-docker-registry-key --docker-server=nexus3.onap.org:10001 --docker-username="$ONAP_USERNAME" --docker-password="$ONAP_PASSWORD" --docker-email="$ONAP_EMAIL" --namespace=onap-log || true
kubectl create secret docker-registry onap-docker-registry-key --docker-server=nexus3.onap.org:10001 --docker-username="$ONAP_USERNAME" --docker-password="$ONAP_PASSWORD" --docker-email="$ONAP_EMAIL" --namespace=onap-mso || true
kubectl create secret docker-registry onap-docker-registry-key --docker-server=nexus3.onap.org:10001 --docker-username="$ONAP_USERNAME" --docker-password="$ONAP_PASSWORD" --docker-email="$ONAP_EMAIL" --namespace=onap-robot || true
echo "Add clusterrolebinding"
kubectl create clusterrolebinding onap-config-admin-binding --clusterrole=cluster-admin --serviceaccount=onap:default || true
kubectl create clusterrolebinding onap-log-admin-binding --clusterrole=cluster-admin --serviceaccount=onap-log:default || true
kubectl create clusterrolebinding onap-mso-admin-binding --clusterrole=cluster-admin --serviceaccount=onap-mso:default || true
kubectl create clusterrolebinding onap-robot-admin-binding --clusterrole=cluster-admin --serviceaccount=onap-robot:default || true
echo "Create Config/Log/Robot"
helm upgrade --install --force onap-config --namespace=onap onap-amsterdam/config
helm upgrade --install --force onap-log --namespace=onap-log onap-amsterdam/log
helm upgrade --install --force onap-robot --namespace=onap-robot onap-amsterdam/robot
export NAMESPACE="onap-mso"
else
echo "skipping onap configuration"
fi
- >
if [ "$TARGET_PROJECT_NAME" == prometheus ]; then
EXTRA_ARGS="--set alertmanager.persistentVolume.enabled=false --set server.persistentVolume.enabled=false --set pushgateway.persistentVolume.enabled=false --set nodeExporter.enabled=false"
elif [ "$TARGET_PROJECT_NAME" == envoy ] && [ "$TARGET_PROJECT_COMMIT_REF_NAME" != master ]; then
EXTRA_ARGS="--set service.name=envoy-stable"
fi
- helm install
--namespace "${NAMESPACE}"
"${DEPLOYMENT_NAME}"
$EXTRA_ARGS
$IMAGE_ARGS
$TAG_ARGS
"${CHART_REPO}"/"${CHART}"
--wait
--timeout 60m
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
untracked: true
expire_in: 5 weeks
paths:
- ./data
e2e:
image: crosscloudci/debian-helm-kubectl:v3.2.4-v1.18.4
stage: End-to-End
script:
- echo "$KUBECONFIG" | base64 -d | tee ./kubeconfig >/dev/null
- export KUBECONFIG=$(pwd)/kubeconfig
- >
if [ "$TARGET_PROJECT_NAME" == so ]; then
ls -al
./cd.sh
else
echo "Enable in .gitlab-ci.yml"
fi
Dashboard:
image: crosscloudci/debian-go
stage: Dashboard-Update
script:
- echo 'test'
# Build-Source VARs
Build-Source:
<<: *build_source
# Project Deploy VARs
App-Deploy:
<<: *cross-project