-
-
Save ferPrieto/faf18600c1f8fc8b73b603c9c5092aeb to your computer and use it in GitHub Desktop.
This script parses the value from the code coverage report file and is able to update the secrets value 'CODE_COVERAGE'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get code coverage generated by Jacoco reports | |
chmod +x $BITRISE_SOURCE_DIR/build/reports/jacoco/index.html | |
CURRENT_COVERAGE=$(cat $BITRISE_SOURCE_DIR/build/reports/jacoco/index.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total//') | |
echo ${CURRENT_COVERAGE//[[:blank:]]/} | |
# Try delete previous value in Bitrise Secrets | |
curl -X DELETE 'https://api.bitrise.io/v0.1/apps/$APP_ID/secrets/CODE_COVERAGE' \ | |
-H 'Content-Type: application/json' \ | |
-H 'Authorization: $BITRISE_PERSONAL_ACCESS_TOKEN'> delete_secret_result.json | |
# Update Code Coverage in Bitrise Secrets | |
curl -X PUT 'https://api.bitrise.io/v0.1/apps/$APP_ID/secrets/CODE_COVERAGE' \ | |
-H "accept: application/json" \ | |
-H "Authorization: $BITRISE_PERSONAL_ACCESS_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"expand_in_step_inputs\": false, \"is_exposed_for_pull_requests\": true, \"is_protected\": false, \"value\": \"$CURRENT_COVERAGE\"}" > secret-result.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment