Home > Net >  How to stop Codemagic in post-clone script?
How to stop Codemagic in post-clone script?

Time:03-21

I added build triggers with a specific tag pattern in codemagic, I want to stop codemagic build in the post-clone script if the latest commit is not from a specific user. Is it possible to stop codemagic or fail in the post clone script?

CodePudding user response:

I found the Codemagic cheat sheet. There is the following script:

- name: Verify Device Farm test
    script: |
      set -e
      set -x
      export AWS_RESULT=$(cat $CM_BUILD_DIR/.scripts/test-result.json | jq -r '.run.result')
      if [ $AWS_RESULT != "PASSED" ] 
      then
        echo "AWS tests did not pass, the result was $AWS_RESULT"
        exit 1
      else 
        echo "AWS tests PASSED!"
      fi  

Maybe a similar logic as in the if/else clause will help you?

CodePudding user response:

If you're using yaml configuration, you can skip the build based on the webhook information already using changesets and conditions.

With post-clone script it's a bit more difficult, but to expand on @mkobuolys's answer:

set -e
set -x
export AUTHOR_NAME=$(git --no-pager show -s --format='%an' $CM_COMMIT)
if [ $AUTHOR_EMAIL != "example_user" ] 
then
  echo "Wrong user"
  exit 1
else 
  echo "Correct user"
fi 

To get the email instead of the name, you can use

  • Related