问题
I'm testing gitlab ci/cd and I'm trying to build a signed APK but my script failed. What should I change or add?
I add variables KEYSTORE_FILE, KEYSTORE_PASSWORD, KEY_ALIAS, KEY_PASSWORD with values.
assembleRelease:
stage: release
script:
- echo $KEYSTORE_FILE | base64 -d > my.keystore
- ./gradlew assembleRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
artifacts:
paths:
- app/build/outputs/apk/release
Error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:packageRelease'.
1 exception was raised by workers:
java.lang.RuntimeException:
com.android.ide.common.signing.KeytoolException: Failed to read key from
store "/builds/juantamad.02072019/2019_samplebuild/my.keystore": null
But it should be successfully
回答1:
Provided you have correct indentations (as posted they are not), the problem is likely to be caused by multi-line command - it just executes - ./gradlew assembleRelease
first, without further arguments
To wrap the long line you can use YAML multi-line strings:
script:
- ...
- >
./gradlew assembleRelease
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
-Pandroid.injected.signing.key.alias=$KEY_ALIAS
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
Read more:
- In YAML, how do I break a string over multiple lines?
- https://gitlab.com/snippets/1717579
--
Another possible cause - if your env var is set as Protected in project settings,
and you are working in a branch which is not Protected.
Then var is not passed to your job
来源:https://stackoverflow.com/questions/56879626/cant-generate-signed-apk-in-gitlab-ci