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

Send more advanced slack messages v2 #324

Merged
merged 3 commits into from
Aug 14, 2017
Merged

Conversation

gurumaia
Copy link
Contributor

@gurumaia gurumaia commented Jun 2, 2017

Based on @ahmetrehaseker's implementation.
This is a change to support slack complex messaging.
See #285 for more details.

ahmetrehaseker and others added 2 commits June 2, 2017 11:29
if attachments doesnot contain fallback set message as fallback

JSONArray converted to String

ReadMe modified

ReadMe modified

test fix
Copy link

@rafi-tvtime rafi-tvtime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. let's do this!

@gurumaia
Copy link
Contributor Author

gurumaia commented Jun 8, 2017

Can someone review this?

@samrocketman
Copy link
Member

samrocketman commented Jun 15, 2017

Hey @gurumaia, I'll take a look as well and try bootstrapping it with https://github.com/samrocketman/jenkins-bootstrap-slack. Please also refer to #320 as I generally am attempting to distance myself from this plugin specifically.

Copy link

@ejohansson ejohansson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, no apparent issues.

Copy link

@ejohansson ejohansson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc looks good to me, test looks good.

@gurumaia
Copy link
Contributor Author

Alright, great @samrocketman. I did see your commits about removing yourself as a maintainer. I can try to step up and help maintain the plugin if you'd like.

@samrocketman
Copy link
Member

@gurumaia you're welcome to step up and maintain. Feel free to check in with @kmadel who, as far as I know, has not relinquished being the other maintainer. I'm sure he wouldn't mind bringing you on board. Feel free to send a message to the developers mailing list, mention Kurt, and this discussion.

@djk
Copy link

djk commented Jul 5, 2017

Would be amazing to have this reviewed and hopefully approved. Is @gurumaia taking it over?

@gurumaia
Copy link
Contributor Author

gurumaia commented Jul 5, 2017

Hey @djk I'll contact @kmadel to see if I can get in. This has been on the back of my mind lately as I've had quite a few rushed days these past few weeks.
Btw, the plugin has been working nicely in my production environment. While this isn't approved, feel free to clone my repo and build using the instructions in the readme.

@djk
Copy link

djk commented Jul 5, 2017

Thanks @gurumaia, I'll check your repo!

Wasn't hassling you, hope it doesn't feel that way. Thanks for the great work.

@gurumaia
Copy link
Contributor Author

gurumaia commented Jul 5, 2017

Absolutely no hassling =).

btw, I didn't actually code this, I just took @ahmetrehaseker's old PR and performed @samrocketman's suggestions.

@djk
Copy link

djk commented Jul 7, 2017

@gurumaia

Ah right, well thanks to @ahmetrehaseker and @samrocketman too!

One thing, not sure where best to mention this but does your PR support "fields": https://api.slack.com/docs/message-attachments#fields

I'm not quite sure how one would enter a JSON array into the example that you provided on the page of your fork.

EDIT: Got it to work with help of a friend, like:

      JSONObject fieldOne = new JSONObject();
        fieldOne.put('title', 'Build');
        fieldOne.put('value', "<${env.BUILD_URL}|${env.BUILD_NUMBER}>");
        fieldOne.put('short', true);
        fields.add(fieldOne);

And repeating for more fields etc.

EDIT: The above doesn't seem to work in regard to actually doing the interpolation of variables. Is there some escaping required?

Thanks again!

@gurumaia
Copy link
Contributor Author

@djk sorry, I missed your edit.
The code you posted seems like it should work fine. What value are you getting in slack?
For reference, here's an example from one of my internal projects:

        String artifactUrl = "${env.NEXUS_URL_NOTIFY}${env.pom_groupId}/${env.pom_artifactId}/${env.pom_new_version}/${env.pom_artifactId}-${env.pom_new_version}.${env.pom_packaging}"

        JSONArray fields = new JSONArray();
        JSONObject field = new JSONObject();
        field.put('title','URL Nexus');
        field.put('value',artifactUrl);
        fields.add(field);
        attachment.put('fields',fields);

@kmadel If you could review this PR, I can go ahead and merge it.
Thanks

@kmadel
Copy link
Contributor

kmadel commented Jul 20, 2017

Decent doc update, it has tests, looks ok to me. I so go for it @gurumaia and thanks.

Copy link

@DaBs DaBs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, has tests, new features are much needed in a lot of cases.

@rafi-tvtime
Copy link

Is this being merged?

@brianespinosa
Copy link

+1 for this feature getting merged now that it appears to have tests and looks good.

@gurumaia
Copy link
Contributor Author

I've merged and now I'm waiting for approval on my request for upload access to actually release it: jenkins-infra/repository-permissions-updater#399

@brianespinosa
Copy link

@gurumaia Any idea on timing to release this? I noticed that your above referenced PR giving you access has been merged. Thanks again for your help taking this over.

@gurumaia
Copy link
Contributor Author

gurumaia commented Sep 1, 2017

Hey @brianespinosa I've finally released it to the update center yesterday. Should be available now. Please test it and let me know if it works well for you.

@ghost
Copy link

ghost commented Oct 6, 2017

Doesn't this revert the fix in 3905e00#diff-282db0eb13a24d1729df3e194a35f6d7 #274 made by @p00j4 ?
So that messages over 4K will be truncated again. Because that is at least what I am seeing in version 2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants