nexus-actions / create-nexus-staging-repo

Avoid split staging repos when publishing to Maven Central
6 stars 2 forks source link

Job does not exit on failure properly #3

Open garyp opened 2 years ago

garyp commented 2 years ago

I was passing an incorrect value for the staging_repository_id argument when running the create-nexus-staging-repo action. However, instead of failing, the job exited successfully. Downstream jobs saw the value of needs.create-staging-repository.outputs.repository_id as "null". You can see an example run at https://github.com/streem/pbandk/runs/4029266895?check_suite_focus=true.

If I run the curl command from https://github.com/nexus-actions/create-nexus-staging-repo/blob/main/entrypoint.sh manually, I see that the output is in fact "null" rather than empty string. Which means the error handling in if [ -z "$stagingRepositoryId" ]; then will never run.

On a related note, it'd be helpful if the script printed the value of $jsonOutput to the log when $stagingRepositoryId is empty or "null". That would've helped me identify the problem much quicker (the JSON output was {"errors":[{"id":"*","msg":"Cannot create Staging Repository, profile with id 'pro.streem' does not exist."}]} in my case).

martinbonnin commented 2 years ago

Thanks for the detailed bug report 👍 . Error handling in bash script is always fun...

I'd be down to rewrite this logic in Kotlin, either by using a Kotlin-compatible base Docker image or (faster) by compiling a small linux Kotlin native binary. @romainbsl any thoughts?