Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2023 20:35
What would you like to do?
This script parses the value from the code coverage report file and is able to update the secrets value 'CODE_COVERAGE'.
# 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 '$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 '$APP_ID/secrets/CODE_COVERAGE' \
-H "accept: application/json" \
-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