Skip to content

Commit

Permalink
Merge pull request #1341 from SUSE/update-release-pipeline
Browse files Browse the repository at this point in the history
Update release pipeline to build both SLE and Opensuse images
  • Loading branch information
nwmac authored Nov 1, 2017
2 parents b8b51ed + 6141909 commit 58b6412
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 19 deletions.
95 changes: 89 additions & 6 deletions deploy/ci/console-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,61 @@ resources:
access_key_id: {{minio-access-key}}
secret_access_key: {{minio-secret-access-key}}
region_name: eu-central-1
- name: helm-chart-values-sle
type: s3
source:
bucket: concourse-stratos-ui
endpoint: {{minio-server-endpoint}}
regexp: temp-artifacts/values.yaml-(?P<version>.*)
access_key_id: {{minio-access-key}}
secret_access_key: {{minio-secret-access-key}}
region_name: eu-central-1
- name: helm-chart-Chart-sle
type: s3
source:
bucket: concourse-stratos-ui
endpoint: {{minio-server-endpoint}}
regexp: temp-artifacts/Chart.yaml-(?P<version>.*)
access_key_id: {{minio-access-key}}
secret_access_key: {{minio-secret-access-key}}
region_name: eu-central-1
- name: helm-chart-tarball-sle
type: s3
source:
bucket: concourse-stratos-ui
endpoint: {{minio-server-endpoint}}
regexp: temp-artifacts/console-(?P<version>.*).tgz
access_key_id: {{minio-access-key}}
secret_access_key: {{minio-secret-access-key}}
region_name: eu-central-1

groups:
- name: tests
jobs:
- build-helm-images
- build-opensuse-helm-images
- build-sle-helm-images
- update-repo
- create-sle-chart
- update-github-release

jobs:
- name: build-helm-images
- name: build-opensuse-helm-images
plan:
- get: stratos-ui
trigger: true
passed: [create-sle-chart]
- do:
- task: generete-certs
timeout: 2m
file: stratos-ui/deploy/ci/tasks/build-images/generate-certs.yml
- task: build
privileged: true
timeout: 30m
timeout: 50m
file: stratos-ui/deploy/ci/tasks/release/build-helm.yml
params:
DOCKER_USERNAME: {{docker-username}}
DOCKER_PASSWORD: {{docker-password}}
BASE_IMAGE: opensuse
- put: helm-chart-values
params:
file: helm-build/values.yaml-*
Expand All @@ -65,17 +96,43 @@ jobs:
params:
file: helm-build/Chart.yaml-*
acl: public-read
- name: build-sle-helm-images
plan:
- get: stratos-ui
trigger: true
- do:
- task: generete-certs
timeout: 2m
file: stratos-ui/deploy/ci/tasks/build-images/generate-certs.yml
- task: build
privileged: true
timeout: 50m
file: stratos-ui/deploy/ci/tasks/release/build-helm.yml
params:
DOCKER_USERNAME: {{staging-repository-username}}
DOCKER_PASSWORD: {{staging-repository-password}}
BASE_IMAGE: {{staging-repo-base-image-tag}}
STAGING_REPOSITORY: {{staging-repository}}
IS_OFFICIAL: "true"
- put: helm-chart-values-sle
params:
file: helm-build/values.yaml-*
acl: public-read
- put: helm-chart-Chart-sle
params:
file: helm-build/Chart.yaml-*
acl: public-read


- name: update-repo
plan:
- get: stratos-ui
passed: [build-helm-images]
passed: [build-opensuse-helm-images]
trigger: true
- get: helm-chart-Chart
passed: [build-helm-images]
passed: [build-opensuse-helm-images]
- get: helm-chart-values
passed: [build-helm-images]
passed: [build-opensuse-helm-images]
- do:
- task: build
privileged: true
Expand All @@ -92,6 +149,32 @@ jobs:
file: helm-chart/*.tgz
acl: public-read

- name: create-sle-chart
plan:
- get: stratos-ui
passed: [build-sle-helm-images]
trigger: true
- get: helm-chart-Chart-sle
passed: [build-sle-helm-images]
- get: helm-chart-values-sle
passed: [build-sle-helm-images]
- do:
- task: build
privileged: true
timeout: 30m
file: stratos-ui/deploy/ci/tasks/release/create-chart-sle.yml
params:
GIT_USER: {{concourse-user}}
GIT_EMAIL: {{concourse-email}}
GITHUB_ORG: {{github-organization}}
GITHUB_REPO: {{github-repository}}
GIT_PRIVATE_KEY: {{github-private-key}}
BASE_IMAGE: "sle"
- put: helm-chart-tarball-sle
params:
file: helm-chart/*.tgz
acl: public-read

- name: update-github-release
plan:
- get: stratos-ui
Expand Down
7 changes: 5 additions & 2 deletions deploy/ci/scripts/Dockerfile.stratos-helm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM alpine:3.6
RUN apk add --update --no-cache ca-certificates git curl
FROM opensuse:latest
ENV VERSION v2.6.1
ENV FILENAME helm-${VERSION}-linux-amd64.tar.gz
RUN zypper in -y curl tar git openssh
RUN curl -L http://storage.googleapis.com/kubernetes-helm/${FILENAME} | tar xzv && \
mv /linux-amd64/helm /bin/helm
RUN mkdir ~/.ssh
RUN touch ~/.ssh/config
RUN echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
19 changes: 13 additions & 6 deletions deploy/ci/tasks/release/build-helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ run:
- |
source /docker-lib.sh
start_docker
cat /etc/docker/daemon.json
# Login to Docker to push images
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} ${STAGING_REPOSITORY};
ROOT_DIR=${PWD}
# Move dev-certs
mv ${ROOT_DIR}/dev-certs-output/dev-certs stratos-ui/dev-certs
cd ${ROOT_DIR}/stratos-ui/deploy/kubernetes
# Login to Docker to push images
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
if [ ! -z "${IS_OFFICIAL}" ]; then
ADD_OFFICIAL_TAG="-cap"
fi
# Build images
./build.sh -T -c
if [ ! -z "${STAGING_REPOSITORY}" ]; then
./build.sh -T -c -b ${BASE_IMAGE} -r ${STAGING_REPOSITORY} -O
else
./build.sh -T -c -b ${BASE_IMAGE}
fi
GIT_TAG="$(git describe $(git rev-list --tags --max-count=1))-$(git rev-parse --short HEAD)"
cp console/values.yaml ${ROOT_DIR}/helm-build/values.yaml-${GIT_TAG}
cp console/Chart.yaml ${ROOT_DIR}/helm-build/Chart.yaml-${GIT_TAG}
cp console/values.yaml ${ROOT_DIR}/helm-build/values.yaml${ADD_OFFICIAL_TAG}-${GIT_TAG}
cp console/Chart.yaml ${ROOT_DIR}/helm-build/Chart.yaml${ADD_OFFICIAL_TAG}-${GIT_TAG}
37 changes: 37 additions & 0 deletions deploy/ci/tasks/release/create-chart-sle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
platform: linux
inputs:
- name: stratos-ui
- name: helm-chart-Chart-sle
- name: helm-chart-values-sle
outputs:
- name: helm-chart
image_resource:
type: docker-image
source:
# Generated using Dockerfile.stratos-helm
repository: ci-registry.ngrok.io:80/stratos-helm
tag: "latest"
insecure_registries: [ "ci-registry.ngrok.io:80" ]

run:
path: sh
args:
- -exc
- |
# Expect this command to fail since k8s isn't available but it will initialise helm locally
helm init || true
ROOT_DIR=$PWD
BASE_IMAGE=${BASE_IMAGE:-opensuse}
STRATOS_UI=${ROOT_DIR}/stratos-ui
cd ${STRATOS_UI}/deploy/kubernetes/
GIT_TAG="$(git describe $(git rev-list --tags --max-count=1))-$(git rev-parse --short HEAD)"
SHORT_GIT_TAG="$(git describe $(git rev-list --tags --max-count=1))"
cp -f ${ROOT_DIR}/helm-chart-values-sle/values.yaml* console/values.yaml
cp -f ${ROOT_DIR}/helm-chart-Chart-sle/Chart.yaml* console/Chart.yaml
# Generate Helm package
helm package console
cp console*.tgz ${ROOT_DIR}/helm-chart/console-helm-chart-cap-${BASE_IMAGE}-${SHORT_GIT_TAG}.tgz
5 changes: 3 additions & 2 deletions deploy/ci/tasks/release/create-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ run:
# Expect this command to fail since k8s isn't available but it will initialise helm locally
helm init || true
ROOT_DIR=$PWD
BASE_IMAGE=${BASE_IMAGE:-opensuse}
STRATOS_UI=${ROOT_DIR}/stratos-ui
cd ${STRATOS_UI}/deploy/kubernetes/
GIT_TAG="$(git describe $(git rev-list --tags --max-count=1))-$(git rev-parse --short HEAD)"
Expand All @@ -32,7 +33,7 @@ run:
# Generate Helm package
helm package console
cp console*.tgz ${ROOT_DIR}/helm-chart/console-helm-chart-${SHORT_GIT_TAG}.tgz
cp console*.tgz ${ROOT_DIR}/helm-chart/console-helm-chart-${BASE_IMAGE}-${SHORT_GIT_TAG}.tgz
cd ${ROOT_DIR}/helm-chart/
if [ -f ${STRATOS_UI}/index.yaml ]; then
cp ${STRATOS_UI}/index.yaml ${ROOT_DIR}/helm-chart/
Expand All @@ -49,7 +50,7 @@ run:
mkdir -p /root/.ssh/
echo "${GIT_PRIVATE_KEY}" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# Update Helm repo
git add index.yaml
git commit -m "Helm repository updated for tag: ${SHORT_GIT_TAG}"
Expand Down
1 change: 1 addition & 0 deletions deploy/ci/tasks/release/update-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ run:
# Upload Helm chart to release
github-release upload -t ${GIT_TAG} --file ${CHART_PACKAGE} --name "console-helm-chart-${GIT_TAG}.tgz"
# Sync changelog
cd ${ROOT_DIR}/stratos-ui
chandler push ${GIT_TAG}
14 changes: 11 additions & 3 deletions deploy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ PROD_RELEASE=false
DOCKER_REGISTRY=docker.io
DOCKER_ORG=splatform
BASE_IMAGE_TAG=opensuse
OFFICIAL_TAG=cap
TAG=$(date -u +"%Y%m%dT%H%M%SZ")

while getopts ":ho:r:t:dTclb" opt; do
ADD_OFFICIAL_TAG="false"
TAG_LATEST="false"
while getopts ":ho:r:t:dTclb:O" opt; do
case $opt in
h)
echo
Expand Down Expand Up @@ -40,6 +42,9 @@ while getopts ":ho:r:t:dTclb" opt; do
c)
CONCOURSE_BUILD="true"
;;
O)
ADD_OFFICIAL_TAG="true"
;;
l)
TAG_LATEST="true"
;;
Expand Down Expand Up @@ -114,7 +119,7 @@ function buildAndPublishImage {
echo Pushing Docker Image ${IMAGE_URL}
docker push ${IMAGE_URL}

if [ ! -z ${TAG_LATEST} ]; then
if [ "${TAG_LATEST}" = "true" ]; then
docker tag ${IMAGE_URL} ${DOCKER_REGISTRY}/${DOCKER_ORG}/${NAME}:latest
docker push ${DOCKER_REGISTRY}/${DOCKER_ORG}/${NAME}:latest
fi
Expand Down Expand Up @@ -158,6 +163,9 @@ function updateTagForRelease {
GIT_HASH=$(git rev-parse --short HEAD)
echo "GIT_HASH: ${GIT_HASH}"
TAG="${TAG}-g${GIT_HASH}"
if [ "${ADD_OFFICIAL_TAG}" = "true" ]; then
TAG=${OFFICIAL_TAG}-${TAG}
fi
echo "New TAG: ${TAG}"
popd > /dev/null 2>&1
}
Expand Down

0 comments on commit 58b6412

Please sign in to comment.