Skip to content

Commit

Permalink
Re-generate pipeline with latest template
Browse files Browse the repository at this point in the history
  • Loading branch information
bgandon committed Dec 4, 2024
1 parent 943d24c commit e2857d6
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 127 deletions.
60 changes: 35 additions & 25 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
# ci/settings.yml and override what needs overridden.
# This uses spruce, so you have some options there.
#
# author: James Hunt <[email protected]>
# created: 2016-03-30
# original author: James Hunt <[email protected]>
# created: 2016-03-30
# maintainer: Benjamin Gandon (Gstack)

meta:
name: (( param "Please name your pipeline" ))
Expand Down Expand Up @@ -43,12 +44,14 @@ meta:
secret_key: (( param "Please set your AWS Secret Key ID" ))

github:
uri: (( concat "[email protected]:" meta.github.owner "/" meta.github.repo ))
owner: (( param "Please specify the name of the user / organization that owns the Github repository" ))
repo: (( param "Please specify the name of the Github repository" ))
branch: master
private_key: (( param "Please generate an SSH Deployment Key for this repo and specify it here" ))
access_token: (( param "Please generate a Personal Access Token and specify it here" ))
uri: (( concat "[email protected]:" meta.github.owner "/" meta.github.repo ))
owner: (( param "Please specify the name of the user / organization that owns the Github repository" ))
repo: (( param "Please specify the name of the Github repository" ))
branch: master
pr_base_branch: (( grab meta.github.branch ))
release_branch: (( grab meta.github.branch ))
private_key: (( param "Please generate an SSH Deployment Key for this repo and specify it here" ))
access_token: (( param "Please generate a Personal Access Token and specify it here" ))

slack:
webhook: (( param "Please specify your Slack Incoming Webhook Integration URL" ))
Expand All @@ -59,8 +62,8 @@ meta:
success_moji: ":airplane_departure:"
upset_moji: ":sadpanda:"
pipeline_url: (( concat meta.url "/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}" ))
fail_link: (( concat "<" meta.slack.pipeline_url "/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}| Concourse Failure! " meta.slack.upset_moji ">" ))
fail_text: '(( concat meta.slack.fail_link " " meta.pipeline ": `${BUILD_JOB_NAME}` job failed" ))'
fail_link: (( concat "<" meta.slack.pipeline_url "/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}| Let's go fix it!>" ))
fail_text: '(( concat meta.pipeline ": `${BUILD_JOB_NAME}` job has failed " meta.slack.upset_moji " " meta.slack.fail_link " :hammer_and_wrench:" ))'

groups:
- name: (( grab meta.pipeline ))
Expand Down Expand Up @@ -98,6 +101,7 @@ jobs:
MODULE: (( grab meta.go.module ))
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand Down Expand Up @@ -163,6 +167,7 @@ jobs:
SUCCESS_MOJI: (( grab meta.slack.success_moji ))
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand Down Expand Up @@ -205,6 +210,7 @@ jobs:
params: { file: version/number }
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand All @@ -219,6 +225,7 @@ jobs:
- { put: version, params: { file: version/number} }
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand All @@ -233,6 +240,7 @@ jobs:
- { put: version, params: { file: version/number } }
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand All @@ -247,6 +255,7 @@ jobs:
- { put: version, params: { file: version/number } }
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand Down Expand Up @@ -279,20 +288,20 @@ jobs:
path: (( concat "./gopath/src/" meta.go.module "/ci/scripts/shipit" ))
args: []
params:
BINARY: (( grab meta.go.binary ))
REPO_ROOT: (( concat "gopath/src/" meta.go.module ))
VERSION_FROM: version/number
RELEASE_NAME: (( grab meta.release ))
RELEASE_ROOT: gh
REPO_OUT: pushme
BINARY: (( grab meta.go.binary ))
REPO_ROOT: (( concat "gopath/src/" meta.go.module ))
VERSION_FROM: version/number
RELEASE_NAME: (( grab meta.release ))
RELEASE_ROOT: gh
REPO_OUT: pushme
NOTIFICATION_OUT: notifications
BRANCH: (( grab meta.github.branch ))
GITHUB_OWNER: (( grab meta.github.owner ))
GITHUB_REPO: (( grab meta.github.repo ))
CMD_PKG: (( grab meta.go.cmd_module ))
STATIC_BINARY: (( grab meta.go.force_static_binary ))
GIT_EMAIL: (( grab meta.git.email ))
GIT_NAME: (( grab meta.git.name ))
RELEASE_BRANCH: (( grab meta.github.release_branch ))
GITHUB_OWNER: (( grab meta.github.owner ))
GITHUB_REPO: (( grab meta.github.repo ))
CMD_PKG: (( grab meta.go.cmd_module ))
STATIC_BINARY: (( grab meta.go.force_static_binary ))
GIT_EMAIL: (( grab meta.git.email ))
GIT_NAME: (( grab meta.git.name ))
- put: version
params: { bump: final }
- put: git
Expand All @@ -314,6 +323,7 @@ jobs:
text_file: notifications/message
on_failure:
put: notify
no_get: true
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
Expand All @@ -329,7 +339,7 @@ resource_types:
- name: pull-request
type: registry-image
source:
repository: teliaoss/github-pr-resource
repository: cfcommunity/github-pr-resource

resources:
- name: image
Expand Down Expand Up @@ -381,4 +391,4 @@ resources:
source:
access_token: (( grab meta.github.access_token ))
repository: (( concat meta.github.owner "/" meta.github.repo ))
base_branch: (( grab meta.github.branch ))
base_branch: (( grab meta.github.pr_base_branch ))
107 changes: 55 additions & 52 deletions ci/repipe
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
# Script for merging together pipeline configuration files
# (via Spruce!) and configuring Concourse.
#
# author: James Hunt <[email protected]>
# Dennis Bell <[email protected]>
# created: 2016-03-04
# original authors: James Hunt <[email protected]>
# Dennis Bell <[email protected]>
# created: 2016-03-04
# maintainer: Benjamin Gandon (Gstack)

need_command() {
local cmd=${1:?need_command() - no command name given}

if [[ ! -x "$(command -v $cmd)" ]]; then
echo >&2 "${cmd} is not installed."
if [[ "${cmd}" == "spruce" ]]; then
echo >&2 "Please download it from https://github.com/geofffranks/spruce/releases"
fi
exit 2
fi
local cmd=${1:?"need_command() - no command name given"}

if [[ ! -x "$(command -v ${cmd})" ]]; then
echo >&2 "${cmd} is not installed."
if [[ "${cmd}" == "spruce" ]]; then
echo >&2 "Please download it from https://github.com/geofffranks/spruce/releases"
fi
exit 2
fi
}

NO_FLY=
Expand All @@ -45,33 +46,35 @@ usage() {
}

open_pipeline() {
url=$(show_pipeline_url)
url=$(show_pipeline_url)
cleanup
if [[ -x /usr/bin/open ]]; then
exec /usr/bin/open "$url"
else
echo "Sorry, but I was not able to automagically open"
echo "your Concourse Pipeline in the browser."
echo
echo "Here's a link you can click on, though:"
echo
echo " $url"
echo
exit 0;
fi
if [[ -x /usr/bin/open ]]; then
exec /usr/bin/open "${url}"
else
echo "Sorry, but I was not able to automagically open"
echo "your Concourse Pipeline in the browser."
echo
echo "Here's a link you can click on, though:"
echo
echo " ${url}"
echo
exit 0;
fi
}

show_pipeline_url() {
spruce merge --skip-eval pipeline.yml ${settings_file} > .deploy.yml
concourse_url=$(spruce json .deploy.yml | jq -r ".meta.url")
team=$(spruce json .deploy.yml | jq -r ".meta.team // \"main\"")
pipeline=$(spruce merge --skip-eval \
--cherry-pick meta.pipeline \
--cherry-pick meta.name \
.deploy.yml | spruce merge - | spruce json | jq -r ".meta.pipeline")

echo "$concourse_url/teams/$team/pipelines/$pipeline"
exit 0
spruce merge --skip-eval pipeline.yml ${settings_file} > .deploy.yml
concourse_url=$(spruce json .deploy.yml | jq -r ".meta.url")
team=$(spruce json .deploy.yml | jq -r ".meta.team // \"main\"")
pipeline=$(
spruce merge --skip-eval \
--cherry-pick meta.pipeline \
--cherry-pick meta.name \
.deploy.yml \
| spruce merge - | spruce json | jq -r ".meta.pipeline"
)
echo "${concourse_url}/teams/${team}/pipelines/${pipeline}"
exit 0
}

for arg do
Expand All @@ -90,16 +93,16 @@ for arg do
esac
done

cd $(dirname $BASH_SOURCE[0])
cd "$(dirname "${BASH_SOURCE[0]}")"
echo >&2 "Working in $(pwd)"
need_command spruce

# Allow for target-specific settings
settings_file="$(ls -1 settings.yml ${CONCOURSE_TARGET:+"settings-${CONCOURSE_TARGET}.yml"} 2>/dev/null | head -n1)"
if [[ -z "$settings_file" ]]
if [[ -z "${settings_file}" ]]
then
echo >&2 "Missing local settings in ci/settings.yml${CONCOURSE_TARGET:+" or ci/settings-${CONCOURSE_TARGET}.yml"}!"
exit 1
echo >&2 "Missing local settings in ci/settings.yml${CONCOURSE_TARGET:+" or ci/settings-${CONCOURSE_TARGET}.yml"}!"
exit 1
fi

echo >&2 "Using settings found in ${settings_file}"
Expand All @@ -113,26 +116,26 @@ trap "cleanup" QUIT TERM EXIT INT
spruce merge pipeline.yml ${settings_file} > .deploy.yml
PIPELINE=$(spruce json .deploy.yml | jq -r '.meta.pipeline // ""')
if [[ -z ${PIPELINE} ]]; then
echo >&2 "Missing pipeline name in ci/settings.yml!"
exit 1
echo >&2 "Missing pipeline name in ci/settings.yml!"
exit 1
fi

TARGET_FROM_SETTINGS=$(spruce json .deploy.yml | jq -r '.meta.target // ""')
if [[ -z ${CONCOURSE_TARGET} ]]; then
TARGET=${TARGET_FROM_SETTINGS}
elif [[ "$CONCOURSE_TARGET" != "$TARGET_FROM_SETTINGS" ]]
TARGET=${TARGET_FROM_SETTINGS}
elif [[ "${CONCOURSE_TARGET}" != "${TARGET_FROM_SETTINGS}" ]]
then
echo >&2 "Target in {$settings_file} differs from target in \$CONCOURSE_TARGET"
echo >&2 " \$CONCOURSE_TARGET: $CONCOURSE_TARGET"
echo >&2 " Target in file: $TARGET_FROM_SETTINGS"
exit 1
echo >&2 "Target in {${settings_file}} differs from target in \$CONCOURSE_TARGET"
echo >&2 " \$CONCOURSE_TARGET: ${CONCOURSE_TARGET}"
echo >&2 " Target in file: ${TARGET_FROM_SETTINGS}"
exit 1
else
TARGET=${CONCOURSE_TARGET}
TARGET=${CONCOURSE_TARGET}
fi

if [[ -z ${TARGET} ]]; then
echo >&2 "Missing Concourse Target in ci/settings.yml!"
exit 1
echo >&2 "Missing Concourse Target in ci/settings.yml!"
exit 1
fi

fly_cmd="${FLY_CMD:-fly}"
Expand All @@ -146,6 +149,6 @@ case "${VALIDATE_PIPELINE}" in
esac

set +x
$fly_cmd --target ${TARGET} ${fly_opts} --config .deploy.yml
${fly_cmd} --target ${TARGET} ${fly_opts} --config .deploy.yml
[[ -n ${VALIDATE_PIPELINE} ]] && exit 0
$fly_cmd --target ${TARGET} unpause-pipeline --pipeline ${PIPELINE}
${fly_cmd} --target ${TARGET} unpause-pipeline --pipeline ${PIPELINE}
Loading

0 comments on commit e2857d6

Please sign in to comment.