Skip to content

Commit 72503ee

Browse files
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.
1 parent 09e33a0 commit 72503ee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.teamcity/build-macos.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ if [[ ! -z "$CFD_CODE_SIGN_KEY" ]]; then
3535
if [[ ! -z "$CFD_CODE_SIGN_PASS" ]]; then
3636
# write private key to disk and then import it keychain
3737
echo -n -e ${CFD_CODE_SIGN_KEY} | base64 -D > ${CODE_SIGN_PRIV}
38-
out=$(security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}" 2>&1)
38+
# we set || true here and for every `security import invoke` because the "duplicate SecKeychainItemImport" error
39+
# will cause set -e to exit 1. It is okay we do this because we deliberately handle this error in the lines below.
40+
out=$(security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}" 2>&1) || true
3941
exitcode=$?
4042
if [ -n "$out" ]; then
4143
if [ $exitcode -eq 0 ]; then
@@ -55,7 +57,7 @@ fi
5557
if [[ ! -z "$CFD_CODE_SIGN_CERT" ]]; then
5658
# write certificate to disk and then import it keychain
5759
echo -n -e ${CFD_CODE_SIGN_CERT} | base64 -D > ${CODE_SIGN_CERT}
58-
out1=$(security import ${CODE_SIGN_CERT} -A 2>&1)
60+
out1=$(security import ${CODE_SIGN_CERT} -A 2>&1) || true
5961
exitcode1=$?
6062
if [ -n "$out1" ]; then
6163
if [ $exitcode1 -eq 0 ]; then
@@ -77,7 +79,7 @@ if [[ ! -z "$CFD_INSTALLER_KEY" ]]; then
7779
if [[ ! -z "$CFD_INSTALLER_PASS" ]]; then
7880
# write private key to disk and then import it into the keychain
7981
echo -n -e ${CFD_INSTALLER_KEY} | base64 -D > ${INSTALLER_PRIV}
80-
out2=$(security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}" 2>&1)
82+
out2=$(security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}" 2>&1) || true
8183
exitcode2=$?
8284
if [ -n "$out2" ]; then
8385
if [ $exitcode2 -eq 0 ]; then
@@ -97,7 +99,7 @@ fi
9799
if [[ ! -z "$CFD_INSTALLER_CERT" ]]; then
98100
# write certificate to disk and then import it keychain
99101
echo -n -e ${CFD_INSTALLER_CERT} | base64 -D > ${INSTALLER_CERT}
100-
out3=$(security import ${INSTALLER_CERT} -A 2>&1)
102+
out3=$(security import ${INSTALLER_CERT} -A 2>&1) || true
101103
exitcode3=$?
102104
if [ -n "$out3" ]; then
103105
if [ $exitcode3 -eq 0 ]; then

0 commit comments

Comments
 (0)