From 4606c30026c410a5c818f14bb0b76679fc481565 Mon Sep 17 00:00:00 2001 From: Steve Taylor Date: Wed, 5 Jul 2017 10:51:06 -0700 Subject: [PATCH] [#147541559] Allow setting Git username and email address in all public tasks Signed-off-by: Chunyi Lyu --- bbl-destroy/task | 6 ++++-- bbl-destroy/task.yml | 6 ++++++ bbl-up/task | 6 ++++-- bbl-up/task.yml | 6 ++++++ bosh-deploy-with-created-release/task.yml | 6 ++++++ bosh-deploy/task.yml | 6 ++++++ shared-functions | 18 +++++++++++++++--- update-integration-configs/task | 6 ++++-- update-integration-configs/task.yml | 7 +++++++ 9 files changed, 58 insertions(+), 9 deletions(-) diff --git a/bbl-destroy/task b/bbl-destroy/task index fc115e8a..432338c3 100755 --- a/bbl-destroy/task +++ b/bbl-destroy/task @@ -1,13 +1,15 @@ #!/bin/bash -xeu +# shellcheck disable=SC1091 +source cf-deployment-concourse-tasks/shared-functions + function commit_bbl_state_file { local root_dir root_dir="${1}" pushd "${root_dir}/bbl-state/${BBL_STATE_DIR}" if [[ -n $(git status --porcelain) ]]; then - git config user.name "CI Bot" - git config user.email "cf-release-integration@pivotal.io" + set_git_config git add --all bbl-state.json git commit -m "Remove bbl-state.json" fi diff --git a/bbl-destroy/task.yml b/bbl-destroy/task.yml index 1ee0912a..4cd7cb27 100644 --- a/bbl-destroy/task.yml +++ b/bbl-destroy/task.yml @@ -25,3 +25,9 @@ params: # - Path to the directory containing the `bbl-state.json` file # - The path is relative to root of the `bbl-state` input # - If unspecified, uses the root of the `bbl-state` input + + GIT_COMMIT_EMAIL: + GIT_COMMIT_USERNAME: + # - Optional + # - You may choose the git committer username and email address by setting these + # - If you leave them blank, they are set to 'CI Bot' and 'cf-release-integration@pivotal.io', respectively diff --git a/bbl-up/task b/bbl-up/task index 1b68ee32..1d4c198f 100755 --- a/bbl-up/task +++ b/bbl-up/task @@ -1,5 +1,8 @@ #!/bin/bash -xeu +# shellcheck disable=SC1091 +source cf-deployment-concourse-tasks/shared-functions + function check_fast_fails() { set +x if [ -z "${LB_DOMAIN}" -a "${BBL_IAAS}" == "gcp" ]; then @@ -29,8 +32,7 @@ function commit_bbl_state_file { pushd "${root_dir}/bbl-state/${BBL_STATE_DIR}" if [[ -n $(git status --porcelain) ]]; then - git config user.name "CI Bot" - git config user.email "cf-release-integration@pivotal.io" + set_git_config git add bbl-state.json git commit -m "Update bbl-state.json" fi diff --git a/bbl-up/task.yml b/bbl-up/task.yml index 86e2863b..757143a4 100644 --- a/bbl-up/task.yml +++ b/bbl-up/task.yml @@ -71,3 +71,9 @@ params: # - Optional # - A label to apply to the bbl environment # - Label will appear in the IaaS metadata/interface + + GIT_COMMIT_EMAIL: + GIT_COMMIT_USERNAME: + # - Optional + # - You may choose the git committer username and email address by setting these + # - If you leave them blank, they are set to 'CI Bot' and 'cf-release-integration@pivotal.io', respectively diff --git a/bosh-deploy-with-created-release/task.yml b/bosh-deploy-with-created-release/task.yml index 6b5b8ae8..ada82b07 100644 --- a/bosh-deploy-with-created-release/task.yml +++ b/bosh-deploy-with-created-release/task.yml @@ -70,3 +70,9 @@ params: # - This is helpful for testing changes around variable generation # - Works well with fresh deployments # - Upgrade deployments are not expected to work with total cred rotation + + GIT_COMMIT_EMAIL: + GIT_COMMIT_USERNAME: + # - Optional + # - You may choose the git committer username and email address by setting these + # - If you leave them blank, they are set to 'CI Bot' and 'cf-release-integration@pivotal.io', respectively diff --git a/bosh-deploy/task.yml b/bosh-deploy/task.yml index 5c1d0838..f90195ce 100644 --- a/bosh-deploy/task.yml +++ b/bosh-deploy/task.yml @@ -67,3 +67,9 @@ params: # - This is helpful for testing changes around variable generation # - Works well with fresh deployments # - Upgrade deployments are not expected to work with total cred rotation + + GIT_COMMIT_EMAIL: + GIT_COMMIT_USERNAME: + # - Optional + # - You may choose the git committer username and email address by setting these + # - If you leave them blank, they are set to 'CI Bot' and 'cf-release-integration@pivotal.io', respectively diff --git a/shared-functions b/shared-functions index 00e43b62..9248aa61 100644 --- a/shared-functions +++ b/shared-functions @@ -19,11 +19,23 @@ function check_input_params() { set -x } -function commit_vars_store { +function set_git_config() { + if [ -z "${GIT_COMMIT_USERNAME}" ]; then + GIT_COMMIT_USERNAME="CI Bot" + fi + + if [ -z "${GIT_COMMIT_EMAIL}" ]; then + GIT_COMMIT_EMAIL="cf-release-integration@pivotal.io" + fi + + git config user.name "${GIT_COMMIT_USERNAME}" + git config user.email "${GIT_COMMIT_EMAIL}" +} + +function commit_vars_store() { pushd vars-store if [[ -n $(git status --porcelain) ]]; then - git config user.name "CI Bot" - git config user.email "cf-release-integration@pivotal.io" + set_git_config git add "${VARS_STORE_FILE}" git commit -m "Update vars-store after deploy" fi diff --git a/update-integration-configs/task b/update-integration-configs/task index 25814809..256b285c 100755 --- a/update-integration-configs/task +++ b/update-integration-configs/task @@ -1,6 +1,9 @@ #!/bin/bash -eu set -o pipefail +# shellcheck disable=SC1091 +source cf-deployment-concourse-tasks/shared-functions + function check_fast_fails() { if [ -z "$VARS_STORE_FILE" ]; then echo "VARS_STORE_FILE has not been set" @@ -18,8 +21,7 @@ function commit_integration_configs { set -x pushd integration-configs if [[ -n $(git status --porcelain) ]]; then - git config user.name "CI Bot" - git config user.email "cf-release-integration@pivotal.io" + set_git_config if [ -f "${CATS_INTEGRATION_CONFIG_FILE}" ]; then git add "${CATS_INTEGRATION_CONFIG_FILE}" diff --git a/update-integration-configs/task.yml b/update-integration-configs/task.yml index 5932fa85..5073b8fa 100644 --- a/update-integration-configs/task.yml +++ b/update-integration-configs/task.yml @@ -38,3 +38,10 @@ params: # - Optional # - CF system base domain e.g. `my-cf.com` # - Should match the value passed to `bosh-deploy` + + GIT_COMMIT_EMAIL: + GIT_COMMIT_USERNAME: + # - Optional + # - You may choose the git committer username and email address by setting these + # - If you leave them blank, they are set to 'CI Bot' and 'cf-release-integration@pivotal.io', respectively +