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

Slack Notification Plugin doesn't seem to use Jenkins' HTTP proxy configuration #978

Open
flabrie opened this issue Jun 6, 2024 · 7 comments
Labels

Comments

@flabrie
Copy link

flabrie commented Jun 6, 2024

Jenkins and plugins versions report

Environment
Jenkins 2.461
Slack Notification Plugin 722.vd07f1ea_7ff40

We use the Slack Notification Plugin on several Jenkins service running on different systems (macOS and Linux), using the same configuration. It works without issue on all Jenkins, except the one RHEL 7 server behind an HTTP proxy.

Jenkins is correctly setup with the proxy settings: all other plugins use it without issue.

The *.slack.com domain name it correctly whitelisted by the proxy. We can even test is from the server command line using a curl command line:

$ echo ${https_proxy}
http://142.101.142.12:8080/
$ curl --request POST --data 'payload={"channel": "#tests", "username":  "Jenkins", "text": "This is a test..."}' https://hooks.slack.com/services/${token}
ok

But through Jenkins, we get a Failure message when the Test Connection button is used on the settings, and no notification are received. And we can find a 404 error in Jenkins' log:

Jun 06, 2024 12:34:12 PM FINE jenkins.plugins.slack.StandardSlackService
Posting: to #jenkins on foobar:  {"attachments":[{"fallback":"Slack/Jenkins plugin: you're all set on https://foobar.com/","color":"good","fields":[{"short":false,"value":"Slack/Jenkins plugin: you're all set on https://foobar.com/"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"#jenkins","username":"Jenkins CLP/CMF"}
Jun 06, 2024 12:34:12 PM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Slack post may have failed. Response: null
Jun 06, 2024 12:34:12 PM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Response Code: 404

And as mentioned above, the HTTP proxy settings are correctly set in Jenkins.

What Operating System are you using (both controller, and any agents involved in the problem)?

Red Hat Enterprise Linux 7

Reproduction steps

  1. Open a session on Jenkins
  2. Go to Settings / System
  3. Make sure the HTTP Proxy Configuration section is configured correctly
  4. Go to the Slack section, and fill the required fields to reach your Slack team account
  5. Hit the Test Connection button.

Expected Results

Expecting Slack Notification Plugin to use Jenkins HTTP Proxy Configuration to send messages.

Actual Results

Slack Notification Plugin doesn't seem to reach Slack Services

Anything else?

No response

Are you interested in contributing a fix?

No response

@flabrie flabrie added the bug label Jun 6, 2024
@timja
Copy link
Member

timja commented Jun 7, 2024

Can you provide your Slack configuration and how you're sending messages through Jenkins?

I suspect its your slack configuration and not a proxy issue.

@flabrie
Copy link
Author

flabrie commented Jun 7, 2024

Here you'll find the Slack configuration: Capture d’écran, le 2024-06-07 à 08 48 04

I get the failure using the Test Connection button. And here it's a Jenkins job usage example:
Capture d’écran, le 2024-06-07 à 08 51 34

Nothing is set in the Advanced settings.

@timja
Copy link
Member

timja commented Jun 7, 2024

Does getting updates for plugins work when you click check for updates? (to verify proxy configuration is right)

@timja
Copy link
Member

timja commented Jun 7, 2024

The code path you are going down should be:

try (CloseableHttpClient client = getHttpClient()) {

protected CloseableHttpClient getHttpClient() {
Jenkins jenkins = Jenkins.getInstanceOrNull();
ProxyConfiguration proxy = jenkins != null ? jenkins.proxy : null;
return HttpClient.getCloseableHttpClient(proxy);
}

https://github.com/jenkinsci/slack-plugin/blob/master/src/main/java/jenkins/plugins/slack/HttpClient.java#L38-L51

https://github.com/jenkinsci/slack-plugin/blob/master/src/main/java/jenkins/plugins/slack/StandardSlackService.java#L200

From reading through I can't see anywhere a proxy is missed and I'd expect more people to have issues if so.

@flabrie
Copy link
Author

flabrie commented Jun 7, 2024

Does getting updates for plugins work when you click check for updates? (to verify proxy configuration is right)

Yes, it works. All other plugins requiring to reach an external server uses the proxy successfully. Here is the HTTP proxy configuration:
Capture d’écran, le 2024-06-07 à 08 59 47

@flabrie
Copy link
Author

flabrie commented Jun 7, 2024

The code path you are going down should be:

try (CloseableHttpClient client = getHttpClient()) {

protected CloseableHttpClient getHttpClient() {
Jenkins jenkins = Jenkins.getInstanceOrNull();
ProxyConfiguration proxy = jenkins != null ? jenkins.proxy : null;
return HttpClient.getCloseableHttpClient(proxy);
}

https://github.com/jenkinsci/slack-plugin/blob/master/src/main/java/jenkins/plugins/slack/HttpClient.java#L38-L51

https://github.com/jenkinsci/slack-plugin/blob/master/src/main/java/jenkins/plugins/slack/StandardSlackService.java#L200

From reading through I can't see anywhere a proxy is missed and I'd expect more people to have issues if so.

Yes, I see. Can you tell me what's the hostname the plugin try to reach? Or is it an IP address? Because only *.slack.com domain is whitelisted for this plugin on our proxy.

@timja
Copy link
Member

timja commented Jun 7, 2024

for your configuration its coemobile.slack.com

All looks configured right

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