From 8dbe18e3d222a0effd4bd55d08173c4f25298ed8 Mon Sep 17 00:00:00 2001 From: Steve Kim <86316075+sbSteveK@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:35:39 -0700 Subject: [PATCH] Escaped password (#198) * deal with escape characters in password --- codebuild/cd/promote-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codebuild/cd/promote-release.yml b/codebuild/cd/promote-release.yml index 13701ef3e0..85c0c4f005 100644 --- a/codebuild/cd/promote-release.yml +++ b/codebuild/cd/promote-release.yml @@ -33,6 +33,7 @@ phases: - aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token/V1 > sonatype_secret - jq fromjson sonatype_secret > sonatype_json - export ST_PASSWORD=$(jq -r '.password' sonatype_json) + - export ESCAPED_PASSWORD=$(printf '%s\n' "$ST_PASSWORD" | sed 's:[\\/&]:\\&:g') - export ST_USERNAME=$(jq -r '.username' sonatype_json) - aws --query "SecretString" secretsmanager get-secret-value --secret-id gpg/IoT/JAVA/V1 > gpg_secret - jq fromjson gpg_secret > gpg_json @@ -40,7 +41,7 @@ phases: - export GPG_CREDENTIAL=$(jq -r '.password' gpg_json) # Use the password from secret manager to update the settings - sed -i 's/sonatype_Principal/'"$ST_USERNAME"'/g' $HOME/.m2/settings.xml - - sed -i 's/sonatype_Credential/'"$ST_PASSWORD"'/g' $HOME/.m2/settings.xml + - sed -i 's/sonatype_Credential/'"$ESCAPED_PASSWORD"'/g' $HOME/.m2/settings.xml - sed -i 's/gpg_Principal/'"$GPG_PRINCIPAL"'/g' $HOME/.m2/settings.xml - sed -i 's/gpg_Credential/'"$GPG_CREDENTIAL"'/g' $HOME/.m2/settings.xml