how can I use parameters from webhook call from GitHub in build?

Dan Halbert

06 Aug, 2018 02:22 AM

I have the following scenario:

When I manually create a release in my repo in GitHub, I want to start an appveyor build which will add a single asset to that newly created release.

My appveyor.yml includes:

artifacts:
- path: 'foo\bar\something.exe'
deploy:
provider: GitHub
force_update: true
auth_token:
secure: xxx

I copied the webhook URL from https://ci.appveyor.com/project/myname/my-projectl/settings. It looks like https://ci.appveyor.com/api/github/webhook?id=blahblah. I entered this URL as a new webhook in https://github.com/myname/my-project/settings/hooks, and set it to trigger on the "Releases Release published in a repository." GitHub event.

When I create a release, the incoming webhook does trigger. The build happens, but then appveyor creates a new release with a tag corresponding to the appveyor build number (1.0.n). Instead, I want it to use the tag_name that is passed in the payload provided with the incoming webhook:

{
"action": "published",
"release": {
"url": "https://api.github.com/repos/nyname/my-project/releases/12345",
...
"tag_name": "4.6.2",
...


How can I get that release.tag_name value into the deploy settings in appveyor.yml? Is it in the environment or available in some other way?

All the webhooks documentation I can find is about outgoing webhooks, not the incoming https://ci.appveyor.com/api/github/webhook?=xxx kind of webhook. I might be looking in the wrong place. Thanks!

1. Support Staff Posted by Owen McDonnell on 06 Aug, 2018 04:37 AM

Check out the NOTE: section in this part of the docs. I think it describes pretty precisely your scenario.

Basically, you can have a tag: $(APPVEYOR_REPO_TAG_NAME) entry in your deployment settings. 2. Posted by Dan Halbert on 06 Aug, 2018 09:32 PM Thanks, that looked promising, so I added a tag: value, per deploy: provider: GitHub force_update: true tag:$(APPVEYOR_REPO_TAG_NAME)
auth_token:
secure: xxx

Unfortunately, the $ reference did not get expanded, and I ended up with a new release with literally the name $(APPVEYOR_REPO_TAG_NAME). From the appveyor log:
Deploying using GitHub provider
Creating "$(APPVEYOR_REPO_TAG_NAME)" release for repository "adafruit/Adafruit_nRF52_nrfutil" tag "$(APPVEYOR_REPO_TAG_NAME)" commit "713ec9b1c44962fe412806c45a08916bbfc00723"...OK
Updating "$(APPVEYOR_REPO_TAG_NAME)" release for repository "adafruit/Adafruit_nRF52_nrfutil" tag "$(APPVEYOR_REPO_TAG_NAME)" commit "713ec9b1c44962fe412806c45a08916bbfc00723"...OK

(I've since deleted that oddly-named release.)

Full appveyor.yml is here: https://github.com/adafruit/Adafruit_nRF52_nrfutil/blob/master/appv.... I think it should work, but ...

EDIT: Similar issue here: https://help.appveyor.com/discussions/problems/14502-setting-appvey...

3. Support Staff Posted by Owen McDonnell on 07 Aug, 2018 04:11 PM

Can you point to the build that the log is from?

4. Posted by Dan Halbert on 07 Aug, 2018 07:11 PM

5. Support Staff Posted by Owen McDonnell on 07 Aug, 2018 08:12 PM

Hmmm. I followed the exact procedure and didn't have the same problem. AppVeyor doesn't show the tag that should be read in the build header either.
Can you confirm that your webhook setup is the same as the screenshots (second screenshot is of the "release" webhook).

6. Posted by Dan Halbert on 07 Aug, 2018 10:29 PM

My webhook screenshot looks the same as yours, except that I only have a release webhook, not aalso pull request and push one.

The content type is application/x-www-form-urlencoded, not application/json.

There were two webhook requests sent, a few minutes apart. The first is below. The second has the $(APPVEYOR_REPO_TAG_NAME) release, because the new release triggered the second. Headers and payload from the first one: Request URL: https://ci.appveyor.com/api/github/webhook?id=g3fnhu985bwc6osi Request method: POST content-type: application/x-www-form-urlencoded Expect: User-Agent: GitHub-Hookshot/4f5b68a X-GitHub-Delivery: 587c3090-99be-11e8-989e-97933de41e77 X-GitHub-Event: release  { "action": "published", "release": { "url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/releases/12278428", "assets_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/releases/12278428/assets", "upload_url": "https://uploads.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/releases/12278428/assets{?name,label}", "html_url": "https://github.com/adafruit/Adafruit_nRF52_nrfutil/releases/tag/0.5.3.post8", "id": 12278428, "node_id": "MDc6UmVsZWFzZTEyMjc4NDI4", "tag_name": "0.5.3.post8", "target_commitish": "master", "name": "appveyor fixes", "draft": false, "author": { "login": "dhalbert", "id": 2847802, "node_id": "MDQ6VXNlcjI4NDc4MDI=", "avatar_url": "https://avatars0.githubusercontent.com/u/2847802?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dhalbert", "html_url": "https://github.com/dhalbert", "followers_url": "https://api.github.com/users/dhalbert/followers", "following_url": "https://api.github.com/users/dhalbert/following{/other_user}", "gists_url": "https://api.github.com/users/dhalbert/gists{/gist_id}", "starred_url": "https://api.github.com/users/dhalbert/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dhalbert/subscriptions", "organizations_url": "https://api.github.com/users/dhalbert/orgs", "repos_url": "https://api.github.com/users/dhalbert/repos", "events_url": "https://api.github.com/users/dhalbert/events{/privacy}", "received_events_url": "https://api.github.com/users/dhalbert/received_events", "type": "User", "site_admin": false }, "prerelease": false, "created_at": "2018-08-06T21:16:08Z", "published_at": "2018-08-06T21:19:04Z", "assets": [ ], "tarball_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/tarball/0.5.3.post8", "zipball_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/zipball/0.5.3.post8", "body": "" }, "repository": { "id": 111049499, "node_id": "MDEwOlJlcG9zaXRvcnkxMTEwNDk0OTk=", "name": "Adafruit_nRF52_nrfutil", "full_name": "adafruit/Adafruit_nRF52_nrfutil", "owner": { "login": "adafruit", "id": 181069, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE4MTA2OQ==", "avatar_url": "https://avatars3.githubusercontent.com/u/181069?v=4", "gravatar_id": "", "url": "https://api.github.com/users/adafruit", "html_url": "https://github.com/adafruit", "followers_url": "https://api.github.com/users/adafruit/followers", "following_url": "https://api.github.com/users/adafruit/following{/other_user}", "gists_url": "https://api.github.com/users/adafruit/gists{/gist_id}", "starred_url": "https://api.github.com/users/adafruit/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/adafruit/subscriptions", "organizations_url": "https://api.github.com/users/adafruit/orgs", "repos_url": "https://api.github.com/users/adafruit/repos", "events_url": "https://api.github.com/users/adafruit/events{/privacy}", "received_events_url": "https://api.github.com/users/adafruit/received_events", "type": "Organization", "site_admin": false }, "private": false, "html_url": "https://github.com/adafruit/Adafruit_nRF52_nrfutil", "description": "Modified version of Nordic's nrfutil 0.5.x for use with the Adafruit Feather nRF52", "fork": false, "url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil", "forks_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/forks", "keys_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/teams", "hooks_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/hooks", "issue_events_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/issues/events{/number}", "events_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/events", "assignees_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/assignees{/user}", "branches_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/branches{/branch}", "tags_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/tags", "blobs_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/git/refs{/sha}", "trees_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/statuses/{sha}", "languages_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/languages", "stargazers_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/stargazers", "contributors_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/contributors", "subscribers_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/subscribers", "subscription_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/subscription", "commits_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/commits{/sha}", "git_commits_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/git/commits{/sha}", "comments_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/comments{/number}", "issue_comment_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/issues/comments{/number}", "contents_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/contents/{+path}", "compare_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/merges", "archive_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/downloads", "issues_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/issues{/number}", "pulls_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/pulls{/number}", "milestones_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/milestones{/number}", "notifications_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/labels{/name}", "releases_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/releases{/id}", "deployments_url": "https://api.github.com/repos/adafruit/Adafruit_nRF52_nrfutil/deployments", "created_at": "2017-11-17T02:50:43Z", "updated_at": "2018-08-06T21:16:48Z", "pushed_at": "2018-08-06T21:16:47Z", "git_url": "git://github.com/adafruit/Adafruit_nRF52_nrfutil.git", "ssh_url": "git@github.com:adafruit/Adafruit_nRF52_nrfutil.git", "clone_url": "https://github.com/adafruit/Adafruit_nRF52_nrfutil.git", "svn_url": "https://github.com/adafruit/Adafruit_nRF52_nrfutil", "homepage": "", "size": 6954, "stargazers_count": 3, "watchers_count": 3, "language": "Python", "has_issues": true, "has_projects": true, "has_downloads": true, "has_wiki": true, "has_pages": false, "forks_count": 2, "mirror_url": null, "archived": false, "open_issues_count": 1, "license": { "key": "bsd-3-clause", "name": "BSD 3-Clause &quot;New&quot; or &quot;Revised&quot; License", "spdx_id": "BSD-3-Clause", "url": "https://api.github.com/licenses/bsd-3-clause", "node_id": "MDc6TGljZW5zZTU=" }, "forks": 2, "open_issues": 1, "watchers": 3, "default_branch": "master" }, "organization": { "login": "adafruit", "id": 181069, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE4MTA2OQ==", "url": "https://api.github.com/orgs/adafruit", "repos_url": "https://api.github.com/orgs/adafruit/repos", "events_url": "https://api.github.com/orgs/adafruit/events", "hooks_url": "https://api.github.com/orgs/adafruit/hooks", "issues_url": "https://api.github.com/orgs/adafruit/issues", "members_url": "https://api.github.com/orgs/adafruit/members{/member}", "public_members_url": "https://api.github.com/orgs/adafruit/public_members{/member}", "avatar_url": "https://avatars3.githubusercontent.com/u/181069?v=4", "description": null }, "sender": { "login": "dhalbert", "id": 2847802, "node_id": "MDQ6VXNlcjI4NDc4MDI=", "avatar_url": "https://avatars0.githubusercontent.com/u/2847802?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dhalbert", "html_url": "https://github.com/dhalbert", "followers_url": "https://api.github.com/users/dhalbert/followers", "following_url": "https://api.github.com/users/dhalbert/following{/other_user}", "gists_url": "https://api.github.com/users/dhalbert/gists{/gist_id}", "starred_url": "https://api.github.com/users/dhalbert/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dhalbert/subscriptions", "organizations_url": "https://api.github.com/users/dhalbert/orgs", "repos_url": "https://api.github.com/users/dhalbert/repos", "events_url": "https://api.github.com/users/dhalbert/events{/privacy}", "received_events_url": "https://api.github.com/users/dhalbert/received_events", "type": "User", "site_admin": false } }  7. Support Staff Posted by Owen McDonnell on 08 Aug, 2018 06:51 AM I see whats happening now. My test was working only because of my "push/pull request" webhook. Since, GitHub needs a tag to associate with a release, the tag creation generates a push event. When i deactivate the "push/pull request" webhook no build is triggered which makes sense since it turns out that AppVeyor doesn't currently respond to "release" events. So I'm not sure how your builds are being triggered. Are all your releases created manually through GitHub UI? We are considering supporting such a scenario but i can't say there is any timeline for such a feature right now. 8. Posted by Dan Halbert on 08 Aug, 2018 06:58 PM Thanks for figuring this out. Yes, we create the releases manually. The idea is to then build some executable versions after we tag and release. We will be using Travis as well to create a PyPi relase of the source code and to build a MacOS executable. I'll think about doing the build on push rather than on release. Right now we can just run things manually - we don't create new releases all that often. I think it might be useful to have access to arbitrary values from the webhook payload, sort like how you provide access to environment values now. Then you wouldn't have to create special-purpose values like $(APPVEYOR_REPO_TAG_NAME) in anticipation of certain use cases.

9. Support Staff Posted by Owen McDonnell on 09 Aug, 2018 04:56 AM

Well, i'm guessing that it was more 'in response to' than 'in anticipation of', but I generally agree with your idea.

I'm still unsure how your build was being triggered with only a 'release' webhook. Is it clear to you?

10. Posted by Dan Halbert on 09 Aug, 2018 12:19 PM

I tried this again, and it didn't fire, as you noted. I must have triggered them by hand from appveyor.com. That might explain why \$(APPVEYOR_REPO_TAG_NAME) wasn't expanded.

Thanks for all your help. This was our first appveyor integration. We'll rethink our workflow based on the current capabilities. Perhaps it's ok to trigger on tag creation, or we can upload the build to elsewhere and just copy it over by hand.

11. Support Staff Posted by Owen McDonnell on 09 Aug, 2018 04:47 PM

No problem.

I'll repost here if there is any development in support for "release events".

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help Blurs the current field

Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

 15 Aug, 2018 05:37 PM Test discussion to check support mailbox 15 Aug, 2018 12:10 AM AppVeyor VM not able to access Microsoft download site 14 Aug, 2018 11:56 PM No new builds are made, it seems stuck 14 Aug, 2018 11:50 PM "Maximum allowed artifact storage size of 1000 Mb will be exceeded." 14 Aug, 2018 10:31 PM AppVeyor link no longer exists
 14 Aug, 2018 09:16 PM Enable Build Schedule for free AppVeyor account 14 Aug, 2018 05:29 PM Options for splitting up build & custom tests 14 Aug, 2018 03:41 PM Stats on how often a build waits for an available job 14 Aug, 2018 11:44 AM AppVeyor failed: Command exited with code 128 14 Aug, 2018 05:47 AM VPN connection failed from Appveyor 13 Aug, 2018 10:47 PM Is it possible to use a Git repository hosted by CodebaseHQ?