Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #374 from Ben16/upgrade-buildpacks-for-multiple-st…
Browse files Browse the repository at this point in the history
…acks

Upgrade buildpacks for multiple stacks
  • Loading branch information
fredwangwang authored Nov 30, 2018
2 parents d291b89 + 0767dbc commit 1cf174b
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 117 deletions.
46 changes: 23 additions & 23 deletions ci/pcf-pipelines/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
atc_creds: &atc_creds
ATC_EXTERNAL_URL: {{atc_external_url}}
ATC_BASIC_AUTH_USERNAME: {{fly_basic_auth_username}}
ATC_BASIC_AUTH_PASSWORD: {{fly_basic_auth_password}}
ATC_TEAM_NAME: {{atc_team_name}}

vsphere_atc_creds: &vsphere_atc_creds
ATC_EXTERNAL_URL: {{atc_external_url}}
ATC_BASIC_AUTH_USERNAME: {{fly_basic_auth_username}}
ATC_BASIC_AUTH_PASSWORD: {{fly_basic_auth_password}}
ATC_TEAM_NAME: vsphere

notify_slack: &notify_slack
put: slack
params:
text: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME failed: $ATC_EXTERNAL_URL/builds/$BUILD_ID"

norm-ci-locks-params: &norm-ci-locks-params
uri: [email protected]:pivotal-cf/norm-ci-locks.git
branch: master
private_key: {{locks_git_ssh_key}}
retry_delay: 1m

groups:
- name: all
jobs:
Expand Down Expand Up @@ -1304,26 +1327,3 @@ jobs:
on_failure:
<<: *notify_slack
####### END VSPHERE OFFLINE

atc_creds: &atc_creds
ATC_EXTERNAL_URL: {{atc_external_url}}
ATC_BASIC_AUTH_USERNAME: {{fly_basic_auth_username}}
ATC_BASIC_AUTH_PASSWORD: {{fly_basic_auth_password}}
ATC_TEAM_NAME: {{atc_team_name}}

vsphere_atc_creds: &vsphere_atc_creds
ATC_EXTERNAL_URL: {{atc_external_url}}
ATC_BASIC_AUTH_USERNAME: {{fly_basic_auth_username}}
ATC_BASIC_AUTH_PASSWORD: {{fly_basic_auth_password}}
ATC_TEAM_NAME: vsphere

notify_slack: &notify_slack
put: slack
params:
text: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME failed: $ATC_EXTERNAL_URL/builds/$BUILD_ID"

norm-ci-locks-params: &norm-ci-locks-params
uri: [email protected]:pivotal-cf/norm-ci-locks.git
branch: master
private_key: {{locks_git_ssh_key}}
retry_delay: 1m
37 changes: 20 additions & 17 deletions tasks/promote-buildpack/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ set -eu
cf api $CF_API_URI --skip-ssl-validation
cf auth $CF_USERNAME $CF_PASSWORD

echo Enabling buildpack ${SOURCE_BUILDPACK_NAME}...
cf update-buildpack $SOURCE_BUILDPACK_NAME --enable

set +e
old_buildpack=$(cf buildpacks | grep "${TARGET_BUILDPACK_NAME}\s")
set -e
if [ -n "$old_buildpack" ]; then
index=$(echo $old_buildpack | cut -d' ' -f2)
name=$(echo $old_buildpack | cut -d' ' -f1)

cf delete-buildpack -f $TARGET_BUILDPACK_NAME

echo Updating buildpack ${SOURCE_BUILDPACK_NAME} index...
cf update-buildpack $SOURCE_BUILDPACK_NAME -i $index
fi

cf rename-buildpack $SOURCE_BUILDPACK_NAME $TARGET_BUILDPACK_NAME
for STACK_NAME in $STACKS;
do
echo Enabling buildpack ${SOURCE_BUILDPACK_NAME} ${STACK_NAME}...
cf update-buildpack $SOURCE_BUILDPACK_NAME -s $STACK_NAME --enable

set +e
old_buildpack=$(cf buildpacks | grep "${TARGET_BUILDPACK_NAME}\s" | grep "${STACK_NAME}")
set -e
if [ -n "$old_buildpack" ]; then
index=$(echo $old_buildpack | cut -d' ' -f2)
name=$(echo $old_buildpack | cut -d' ' -f1)

cf delete-buildpack -f $TARGET_BUILDPACK_NAME -s $STACK_NAME

echo Updating buildpack ${SOURCE_BUILDPACK_NAME} ${STACK_NAME} index...
cf update-buildpack $SOURCE_BUILDPACK_NAME -s $STACK_NAME -i $index
fi

cf rename-buildpack $SOURCE_BUILDPACK_NAME $TARGET_BUILDPACK_NAME -s $STACK_NAME
done
2 changes: 2 additions & 0 deletions tasks/promote-buildpack/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
tag: 1.0.28


inputs:
Expand All @@ -30,6 +31,7 @@ params:
CF_PASSWORD:
SOURCE_BUILDPACK_NAME:
TARGET_BUILDPACK_NAME:
STACKS:

run:
path: pcf-pipelines/tasks/promote-buildpack/task.sh
26 changes: 15 additions & 11 deletions tasks/stage-buildpack/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ set -eu
cf api $CF_API_URI --skip-ssl-validation
cf auth $CF_USERNAME $CF_PASSWORD

set +e
existing_buildpack=$(cf buildpacks | grep "${BUILDPACK_NAME}\s")
set -e
if [ -z "${existing_buildpack}" ]; then
COUNT=$(cf buildpacks | grep --regexp=".zip" --count)
NEW_POSITION=$(expr $COUNT + 1)
cf create-buildpack $BUILDPACK_NAME buildpack/*.zip $NEW_POSITION --enable
else
index=$(echo $existing_buildpack | cut -d' ' -f2)
cf update-buildpack $BUILDPACK_NAME -p buildpack/*.zip -i $index --enable
fi

for STACK_NAME in $STACKS;
do
set +e
existing_buildpack=$(cf buildpacks | grep "${BUILDPACK_NAME}\s" | grep "${STACK_NAME}")
set -e
if [ -z "${existing_buildpack}" ]; then
COUNT=$(cf buildpacks | grep --regexp=".zip" --count)
NEW_POSITION=$(expr $COUNT + 1)
cf create-buildpack $BUILDPACK_NAME buildpack/*-$STACK_NAME-*.zip $NEW_POSITION --enable
else
index=$(echo $existing_buildpack | cut -d' ' -f2)
cf update-buildpack $BUILDPACK_NAME -p buildpack/*-$STACK_NAME-*.zip -s $STACK_NAME -i $index --enable
fi
done
2 changes: 2 additions & 0 deletions tasks/stage-buildpack/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
tag: 1.0.28


inputs:
Expand All @@ -30,6 +31,7 @@ params:
CF_USERNAME:
CF_PASSWORD:
BUILDPACK_NAME:
STACKS:

run:
path: pcf-pipelines/tasks/stage-buildpack/task.sh
26 changes: 26 additions & 0 deletions tasks/upgrade-buildpack/task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -eu

# Copyright 2017-Present Pivotal Software, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cf api $CF_API_URI --skip-ssl-validation
cf auth $CF_USERNAME $CF_PASSWORD

for STACK_NAME in $STACKS;
do
echo Upgrading ${TARGET_BUILDPACK_NAME} ${STACK_NAME}...
cf update-buildpack $TARGET_BUILDPACK_NAME -s $STACK_NAME -p buildpack/*.zip --enable
done
37 changes: 37 additions & 0 deletions tasks/upgrade-buildpack/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2017-Present Pivotal Software, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
platform: linux

image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
tag: 1.0.28


inputs:
- name: buildpack
- name: pcf-pipelines

params:
CF_API_URI:
CF_USERNAME:
CF_PASSWORD:
TARGET_BUILDPACK_NAME:
STACKS:

run:
path: pcf-pipelines/tasks/upgrade-buildpack/task.sh
Loading

0 comments on commit 1cf174b

Please sign in to comment.