slack-plugin icon indicating copy to clipboard operation
slack-plugin copied to clipboard

Support emoji reactions across runs/restarts

Open biolauri opened this issue 5 years ago • 4 comments

Your checklist for this issue

  • [x] Jenkins version Jenkins 2.235.5
  • [x] Plugin version Slack Notification Plugin 2.43
  • [x] OS Linux 4.19.112+

Description

As stated in the Readme, I'll file an issue as I wish to have support for Emoji reactions across restarts and pipeline runs. The latter one is especially useful for me as I trigger a Slack message by post { failure { } } and want to mark it resolved by a green check mark emoji with post { fixed { } }. This is currently not possible as I can't store the message/thread ID for subsequent runs and have to use the object returned by slackSend (which I can not store).

My current workaround is to post an answer to the message/thread ID (which works solely by ID) but it'd be much easier to have an emoji reaction which is shown directly instead of an answer.

biolauri avatar Oct 12 '20 22:10 biolauri

I think this could already be possible: https://github.com/jenkinsci/slack-plugin/blob/0b18810ac0b258fef9897621ced6d679125a5095/src/main/java/jenkins/plugins/slack/workflow/SlackResponse.java#L23

The SlackResponse constructor can take an JSONObject. Also serialization looks good:

def response = slackSend(message: "Hello World!")
writeJSON(json: response, file: 'response.json')
archiveArtifacts('response.json') // or stash(includes: 'response.json', name: 'slack_response')

Gives you something like this:

{"threadId":"XXXXXXXXXXX:123123123.000000","channelId":"XXXXXXXXXXX","ts":"1234000000.000000"}

mietzen avatar Nov 24 '20 14:11 mietzen

^^ not ideal, would be good to have a clean fix, maybe just a slackAddReactionStep unless @jetersen you have any ideas.

timja avatar Nov 24 '20 14:11 timja

^^ not ideal, would be good to have a clean fix, maybe just a slackAddReactionStep unless @jetersen you have any ideas.

Of course :laughing: But I'm curious, where would you stash the slackResponseObject in between runs?

mietzen avatar Nov 24 '20 14:11 mietzen

^^ not ideal, would be good to have a clean fix, maybe just a slackAddReactionStep unless @jetersen you have any ideas.

Of course 😆 But I'm curious, where would you stash the slackResponseObject in between runs?

the step would just require the threadId, you wouldn't need the whole object

timja avatar Nov 24 '20 15:11 timja