From 72503eeaaac9a6186fcafa6fac5f9023da6ee70c Mon Sep 17 00:00:00 2001 From: Sudarsan Reddy Date: Mon, 5 Dec 2022 15:18:00 +0000 Subject: [PATCH] TUN-6984: [CI] Ignore security import errors for code_sigining This PR lets the script skip if the `security import` command exits with a 1. This is okay becuase this script manually checks this exit code to validate if its a duplicate error and if its not, returns. --- .teamcity/build-macos.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.teamcity/build-macos.sh b/.teamcity/build-macos.sh index 4c461083..b5f43f87 100755 --- a/.teamcity/build-macos.sh +++ b/.teamcity/build-macos.sh @@ -35,7 +35,9 @@ if [[ ! -z "$CFD_CODE_SIGN_KEY" ]]; then if [[ ! -z "$CFD_CODE_SIGN_PASS" ]]; then # write private key to disk and then import it keychain echo -n -e ${CFD_CODE_SIGN_KEY} | base64 -D > ${CODE_SIGN_PRIV} - out=$(security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}" 2>&1) + # we set || true here and for every `security import invoke` because the "duplicate SecKeychainItemImport" error + # will cause set -e to exit 1. It is okay we do this because we deliberately handle this error in the lines below. + out=$(security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}" 2>&1) || true exitcode=$? if [ -n "$out" ]; then if [ $exitcode -eq 0 ]; then @@ -55,7 +57,7 @@ fi if [[ ! -z "$CFD_CODE_SIGN_CERT" ]]; then # write certificate to disk and then import it keychain echo -n -e ${CFD_CODE_SIGN_CERT} | base64 -D > ${CODE_SIGN_CERT} - out1=$(security import ${CODE_SIGN_CERT} -A 2>&1) + out1=$(security import ${CODE_SIGN_CERT} -A 2>&1) || true exitcode1=$? if [ -n "$out1" ]; then if [ $exitcode1 -eq 0 ]; then @@ -77,7 +79,7 @@ if [[ ! -z "$CFD_INSTALLER_KEY" ]]; then if [[ ! -z "$CFD_INSTALLER_PASS" ]]; then # write private key to disk and then import it into the keychain echo -n -e ${CFD_INSTALLER_KEY} | base64 -D > ${INSTALLER_PRIV} - out2=$(security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}" 2>&1) + out2=$(security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}" 2>&1) || true exitcode2=$? if [ -n "$out2" ]; then if [ $exitcode2 -eq 0 ]; then @@ -97,7 +99,7 @@ fi if [[ ! -z "$CFD_INSTALLER_CERT" ]]; then # write certificate to disk and then import it keychain echo -n -e ${CFD_INSTALLER_CERT} | base64 -D > ${INSTALLER_CERT} - out3=$(security import ${INSTALLER_CERT} -A 2>&1) + out3=$(security import ${INSTALLER_CERT} -A 2>&1) || true exitcode3=$? if [ -n "$out3" ]; then if [ $exitcode3 -eq 0 ]; then