Skip to content

Commit 885c60f

Browse files
committed
travisify.sh: decrypt only when applicable
The "travis encrypt-file" directive adds the openssl decryption command to before_install, but does not guard it. So if the key and iv variables are unavailable, the decryption -- and hence the build -- will fail. We need to guard against this situation.
1 parent c12abb6 commit 885c60f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

travisify.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ EOL
180180
# NB: We have to copy the file first, so that --add does the right thing.
181181
$EXEC cp "$signingKeySourceFile" "$signingKeyDestFile"
182182
$EXEC travis encrypt-file "$signingKeyDestFile" "$signingKeyDestFile.enc" --add --repo "$repoSlug"
183+
# NB: Decrypt only when secure env vars are set.
184+
# Without this adjustment, all PR builds will fail.
185+
$EXEC perl -0777 -i -pe 's/\n- (openssl aes-256-cbc)/\n- test "\$TRAVIS_SECURE_ENV_VARS" = true &&\n \1/igs' .travis.yml
183186
$EXEC rm -f "$signingKeyDestFile"
184187
$EXEC git add "$travisConfig" "$signingKeyDestFile.enc"
185188
$EXEC git commit -m "Travis: add encrypted GPG signing keypair"
@@ -195,7 +198,7 @@ test -d "$credentialsDir" ||
195198
"Please contact a SciJava administrator to receive a copy of this content."
196199

197200
# check prerequisites
198-
check git sed xmllint travis
201+
check git sed perl xmllint travis
199202

200203
# parse arguments
201204
EXEC=:

0 commit comments

Comments
 (0)