forked from che-incubator/kubernetes-image-puller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cico_functions.sh
68 lines (58 loc) · 1.98 KB
/
cico_functions.sh
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
#!/bin/bash
function load_jenkins_vars() {
if [ -e "jenkins-env.json" ]; then
eval "$(./env-toolkit load -f jenkins-env.json \
DEVSHIFT_TAG_LEN \
QUAY_ECLIPSE_CHE_USERNAME \
QUAY_ECLIPSE_CHE_PASSWORD \
JENKINS_URL \
GIT_BRANCH \
GIT_COMMIT \
BUILD_NUMBER \
ghprbSourceBranch \
ghprbActualCommit \
BUILD_URL \
ghprbPullId)"
fi
}
function install_deps() {
REGISTRY="quay.io"
# Update machine, get required deps in place
/usr/sbin/setenforce 0 || true
yum install -d1 -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -d1 -y docker-ce \
git \
make
systemctl start docker
# Login to quay.io
docker login -u "${QUAY_ECLIPSE_CHE_USERNAME}" -p "${QUAY_ECLIPSE_CHE_PASSWORD}" "${REGISTRY}"
}
function build() {
LOCAL_IMAGE_NAME="kubernetes-image-puller"
docker build -t ${LOCAL_IMAGE_NAME} -f ./docker/Dockerfile .
}
function set_git_commit_tag() {
GIT_COMMIT_TAG=$(echo "$GIT_COMMIT" | cut -c1-"${DEVSHIFT_TAG_LEN}")
export GIT_COMMIT_TAG
}
# Simplify tagging and pushing
function tag_and_push_ci() {
REGISTRY="quay.io"
ORGANIZATION="eclipse"
IMAGE="kubernetes-image-puller"
LOCAL_IMAGE_NAME="kubernetes-image-puller"
set_git_commit_tag
docker tag ${LOCAL_IMAGE_NAME} "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${GIT_COMMIT_TAG}"
docker push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${GIT_COMMIT_TAG}"
docker tag ${LOCAL_IMAGE_NAME} "${REGISTRY}/${ORGANIZATION}/${IMAGE}:latest"
docker push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:latest"
}
function tag_and_push_nightly() {
REGISTRY="quay.io"
ORGANIZATION="eclipse"
IMAGE="kubernetes-image-puller"
LOCAL_IMAGE_NAME="kubernetes-image-puller"
docker tag ${LOCAL_IMAGE_NAME} "${REGISTRY}/${ORGANIZATION}/${IMAGE}:nightly"
docker push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:nightly"
}