touch up README; clean up error

This commit is contained in:
Dan Ballard 2018-07-07 18:29:02 -05:00
parent 7fd77fa64b
commit 4dcfaf559a
2 changed files with 7 additions and 7 deletions

View File

@ -1,14 +1,16 @@
Create a user on Gogs for posting build notifications (like 'buildbot') and generate a token for it. Insert the token as a drone secret. Create a user on Gogs for posting build notifications (like 'buildbot') and generate a token for it. Insert the token as a drone secret. (Replace $VALUE with the actual token)
drone secret add dan/gogs-notify-test --name gogs_account_token --value $VALUE --event pull-request --event push --event tag --event deployment drone secret add dan/gogs-notify-test --name gogs_account_token --value $VALUE --event pull_request
Use in drone.yml: Use in .drone.yml:
notify-gogs: notify-gogs:
image: mindstab/drone-gogs image: mindstab/drone-gogs
when: when:
event: pull_request event: pull_request
secrets: [gogs_account_token] secrets: [gogs_account_token]
gogs_url: https://git.openprivacy.ca gogs_url: https://git.yourdomain.com
- gogs_url should not end in '/'. Example with path: https://git.yourdomain.com/gogs

View File

@ -3,13 +3,11 @@
URL="$PLUGIN_GOGS_URL/api/v1/repos/$DRONE_REPO/issues/$DRONE_PULL_REQUEST/comments" URL="$PLUGIN_GOGS_URL/api/v1/repos/$DRONE_REPO/issues/$DRONE_PULL_REQUEST/comments"
RESULT=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GOGS_ACCOUNT_TOKEN" -H "Content-Type: application/json" -d "{\"Body\": \"Drone Build Status: $DRONE_BUILD_STATUS\n\n$DRONE_BUILD_LINK\"}" -X POST $URL) RESULT=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GOGS_ACCOUNT_TOKEN" -H "Content-Type: application/json" -d "{\"Body\": \"Drone Build Status: $DRONE_BUILD_STATUS\n\n$DRONE_BUILD_LINK\"}" -X POST $URL)
CURL_RESULT=$?
if [ $RESULT -eq 201 ] if [ $RESULT -eq 201 ]
then then
echo "Success posting to $URL" echo "Success posting to $URL"
else else
echo "ERROR posting to $URL" echo "ERROR HTTP $RESULT posting to $URL"
echo "ERROR http: $RESULT curl: $CURL_RESULT"
exit 1 exit 1
fi fi