Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes variable does not serialize to Json #98

Closed
opm99 opened this issue Feb 27, 2018 · 3 comments
Closed

Changes variable does not serialize to Json #98

opm99 opened this issue Feb 27, 2018 · 3 comments
Labels
Milestone

Comments

@opm99
Copy link

opm99 commented Feb 27, 2018

Expected Behavior

When template contains configuration:

// other json ..
"changes": ${changes}

Payload would contain fields related to the VCS changes that triggered the build (shown in https://github.com/tcplugins/tcWebHooks/wiki/Example-Webhook-Output---JSON)

Current Behavior

Changes variable does not serialize to Json

"changes": "[webhook.teamcity.payload.content.WebHooksChanges@7e8231]"

Steps to Reproduce (for bugs)

  1. Create a template through UI
  2. Add following json to a Build event template (for build finished/started)
{
	"build": {
		"buildTypeId": "${buildTypeId}",
		"buildId": "${teamcity.build.id}",
	},
	"changes": "${changes}"
}
  1. Set up a webhook for Build started/finished on a TC build that is triggered for a commit
  2. Observe data received on Webhook Target URL

Your Environment

  • tcWebHooks Version: 1.1-alpha15.216.313
  • TeamCity Version: 2017.2.1
  • TeamCity server Operating System: Windows 2012
  • Are you using a WebHook Template?: Yes

Example Configuration (xml)

@netwolfuk netwolfuk added this to the v1.1 milestone Feb 27, 2018
@netwolfuk netwolfuk added the bug label Feb 27, 2018
@netwolfuk
Copy link
Member

Thanks for finding that. All of the object ones in the model will probably have the same issue.

@netwolfuk
Copy link
Member

netwolfuk commented Apr 14, 2018

Thinking about this some more, probably all json fields need to be "serialised".
For example, a variable containing any json reserved character will also break the payload. eg, []{}"'

netwolfuk added a commit that referenced this issue May 2, 2018
Serialises anything that is not a String,Integer or Boolean as JSON (for
the jsonTemplate template.

Seems to have broken the "UNRESOLVED" fallback.
@netwolfuk
Copy link
Member

netwolfuk commented May 2, 2018

I have added support to the VariableResolver so that any item that is not String, Integer or Boolean is passed through a JSON parser provided by the template. It's in a separate branch, and you're welcome to try a build from here.

However, I've realised that the format is fixed, and not really that useful, unless you can access parts of it. I suppose if you're post processing it on the server side once the webhook is delivered, it might be ok, but if you are wanting to do something smarter with the values inside the template, you will need a smarter templating tool.
I have therefore also raised issue #103 so that templates can have more logic inside them.

netwolfuk added a commit that referenced this issue Jul 18, 2018
Serialises anything that is not a String,Integer or Boolean as JSON (for
the jsonTemplate template).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants