Skip to content

Conversation

KojiNakamaru
Copy link
Contributor

@KojiNakamaru KojiNakamaru commented Jun 4, 2024

With the latest plugin ( https://github.com/jenkinsci/slack-plugin/releases/tag/715.v1cfed1b_9c63c ), the following slackUploadFile() cannot finish in my environment, which has roughly 5300 public/private channels. slackUploadFile() internally causes Rate limited by Slack, retrying in 30000ms many times.

pipeline {
    agent {
        node {
            label 'master'
        }
    }
    stages {
        stage('send') {
            steps {
                script {
                    sh 'echo hello > hello.txt'
                    slackUploadFile(channel: 'GXXXXXXXXXX', filePath: 'hello.txt', initialComment: "test")
                }
            }
        }
    }
}

If a channel is specified by its ID, getChannelId() can avoid many conversations.list calls. 894f6ea allows getChannelId() to return immediately if channelName matches the pattern of ID.

I also experimentally found that conversations.list with types=public_channel,private_channel requires much more API calls than conversations.list with two separate types=public_channel and types=private_channel. 48d9152 splits convertChannelNameToId() into two methods, one for types=public_channel and another for types=private_channel. A new parameter limit=999 is also added to reduce API calls further.

Testing done

The code was packaged by mvn package and passed existing tests. The resulting hpi was installed on a jenkins server (version 2.460) and was confirmed to run correctly.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@KojiNakamaru KojiNakamaru requested a review from a team as a code owner June 4, 2024 18:14
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Thanks!

I was testing on a workspace with ~2000 channels and had similar issues but this mostly worked as long at the cache didn't get invalidated immediately.

untested but looks good

@timja timja merged commit d07f1ea into jenkinsci:master Jun 4, 2024
@KojiNakamaru KojiNakamaru deleted the feature/enhanced_channel_id_retrieval branch June 5, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants