File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ pipelines:
3535 clean_workspace : true
3636 jobs :
3737 code :
38+ secure_variables :
39+ VAULT_TOKEN : " AES:oo4qyY+eEf1piu8V4vy4hg==:nnH/4ulwI2JgjBtBiR+LGtB+PLLWVdtsCm+CIgjNHwj+qYXlvxWbN0+RS/tSi60N"
3840 elastic_profile_id : w.c1.m1024.e5
3941 tasks :
4042 - exec :
Original file line number Diff line number Diff line change 22
33set -e
44
5+ SECRET_OPS_VERSION=" 0.6.2"
56RELEASER_VERSION=" 2.1.0"
7+
68RELEASER_FILE=" ops/releaser-${RELEASER_VERSION} "
9+ SECRET_OPS_FILE=" ops/secret-ops"
10+ SECRET_OPS_TAR_FILE=" ops/secret-ops-${SECRET_OPS_VERSION} .tar.gz"
711
812mkdir -p ops
913if [[ ! -f $RELEASER_FILE ]]; then
1014 wget --quiet -O $RELEASER_FILE https://github.com/kudulab/releaser/releases/download/${RELEASER_VERSION} /releaser
1115fi
1216source $RELEASER_FILE
1317
18+ if [[ ! -f $SECRET_OPS_TAR_FILE ]]; then
19+ wget --quiet -O $SECRET_OPS_TAR_FILE https://github.com/kudulab/secret-ops/releases/download/${SECRET_OPS_VERSION} /secret-ops.tar.gz
20+ tar -xf $SECRET_OPS_TAR_FILE -C ops
21+ fi
22+ source $SECRET_OPS_FILE
23+
1424command=" $1 "
1525case " ${command} " in
1626 set_version)
@@ -31,6 +41,8 @@ case "${command}" in
3141 ;;
3242 publish)
3343 # publish the just released version
44+ GITHUB_TOKEN=$( vault read -field=token secret/gocd/github_releases)
45+ export GITHUB_TOKEN
3446 VERSION=$( releaser::get_last_git_tagged_version)
3547 releaser::prepare_github_release_bin
3648 $GHRELEASE_BIN release \
@@ -46,6 +58,12 @@ case "${command}" in
4658 --name " docker-ops" \
4759 --file src/docker-ops
4860 ;;
61+ generate_vault_token)
62+ vault_token=$( vault token create -ttl=48h -policy=gocd -field token -metadata gocd_renew=true)
63+ secured_token_gocd=$( secret_ops::encrypt_with_gocd_top " ${vault_token} " )
64+ echo " Generated token: ${vault_token} and encrypted by GoCD server"
65+ secret_ops::insert_vault_token_gocd_yaml " ${secured_token_gocd} "
66+ ;;
4967 * )
5068 echo " Invalid command: '${command} '"
5169 exit 1
You can’t perform that action at this time.
0 commit comments