I am trying to write a custom notification plugin based on
https://github.com/gocd-contrib/notification-skeleton-plugin and I can't figure out how to get the repository URL from the StageStatusRequest request body. May I ask for a quick help?
The URL is located here:
{"pipeline":{"name":"notif-test","counter":"15","group":"My-group","build-cause":[{"material":{"git-configuration":{"shallow-clone":false,"branch":"main","url":"g...@my.git.server:mygroup/dummy.git"} ...
The type of request.pipeline.buildCause.get(0).material.get("git-configuration") is com.google.gson.internal.LinkedTreeMap and when I output its contents in the log it's
{shallow-clone=false, branch=main, url=g...@my.git.server:mygroup/dummy.git}
but when I further try to get the URL string like this
request.pipeline.buildCause.get(0).material.get("git-configuration").get("url")
the code doesn't compile with:
/plugin/src/main/java/com/example/notification/executors/StageStatusRequestExecutor.java:71: error: cannot find symbol
LOG.info(String.format("DEBUG in StageStatusRequestExecutor sendNotification url=%s", request.pipeline.buildCause.get(0).material.get("git-configuration").get("url")));
symbol: method get(String)
location: class Object
(the error indicator ^ points to the dot next to get("url")). How could I get the URL value from the map? Do I have to pass something else as the key to get() ? Not a Java man so may be missiong something very basic here.
Thanks a lot.