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

Commit

Permalink
Handle stack association when upgrading buildpacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Joyce committed Oct 29, 2018
1 parent f178524 commit 0dac6cc
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 76 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
1 change: 1 addition & 0 deletions tasks/promote-buildpack/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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
1 change: 1 addition & 0 deletions tasks/stage-buildpack/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ params:
CF_USERNAME:
CF_PASSWORD:
BUILDPACK_NAME:
STACKS:

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

0 comments on commit 0dac6cc

Please sign in to comment.