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

Allow slack to post through a proxy #148

Closed
trevcor opened this issue Nov 10, 2015 · 17 comments
Closed

Allow slack to post through a proxy #148

trevcor opened this issue Nov 10, 2015 · 17 comments

Comments

@trevcor
Copy link

trevcor commented Nov 10, 2015

Would be a great feature to allow slack to post through a proxy for cases where Jenkins is running behind a firewall.

@samrocketman
Copy link
Member

I don't actively develop this plugin. I maintain pull requests and releases. Contributions providing this functionality are welcome!

@serg3k
Copy link
Contributor

serg3k commented Nov 19, 2015

@trevcor you mean HTTP/HTTPS proxy?
There is already a similar issue #102

@okram999
Copy link

won't this proxy setting on the jenkins help here? Don't have an env to test. https://wiki.jenkins-ci.org/display/JENKINS/JenkinsBehindProxy

@tonka3000
Copy link

@okram999 this does not work with the actual version, but the git plugin use it, so it should be possible to use the information.

@facastagnini
Copy link

Guys have you seen #171 and #253 ?

@serg3k
Copy link
Contributor

serg3k commented Mar 21, 2017

I think this also should have been resolved in #156 #299
Will test in my enterprise environment

@caleyg
Copy link

caleyg commented Oct 19, 2017

Can anyone please give me some insight here. I'm trying to use this plugin in my Jenkins Pipeline build behind a proxy in an enterprise environment.

slackSend isn't honoring http_proxy, https_proxy, or HTTP_PROXY, HTTPS_PROXY or -Dhttp.proxyHost or -Dhttps.proxyHost.

I know Jenkins use the proxy by leveraging one of the environment variables above, because I'm able to do things like install plugins from the plugin manager, and use the proxy in various other build tasks.

But consistently the slack plugin just times out when connecting to slack.com

I'm very close to pivoting and leveraging curl to send my requests... I've tried this with slack plugin 2.2 and slack 2.3

@kedziorm
Copy link

Could you be so kind and tell me what is the status?

I can confirm that setting proxy according to https://wiki.jenkins.io/display/JENKINS/JenkinsBehindProxy seems to not work for the Slack Notification plugin.

@timja
Copy link
Member

timja commented Nov 28, 2018

PRs welcome...

@Eriten
Copy link

Eriten commented Mar 12, 2019

@timja Since Slack doesn't respect the proxy set through JVM arguments, would it make sense to use the suggested solution in #171. It's not the cleanest solution but it "can" work. When time is available, I'd want to look into the codebase to see if there's a more elegant solution. It sounds to me that it was able to use -Dhttp.proxyHost, but until some point, it stopped working...

@Eriten
Copy link

Eriten commented Mar 12, 2019

I've made some progress in investigating this issue.

Problem
The proxy is not respected because ProxyConfiguration needs to be set in Jenkins. This is not set through passing JVM http.proxyX arguments (https://github.com/jenkinsci/slack-plugin/blob/master/src/main/java/jenkins/plugins/slack/StandardSlackService.java#L215).

Solution
Follow geerlingguy/ansible-role-jenkins#28 to set up ProxyConfiguration at startup and your Slack plugin should respect the proxy before hitting your Slack URL.

@timja
Copy link
Member

timja commented Mar 12, 2019

ProxyConfiguration is the way jenkins does it,

So that works?

@Eriten
Copy link

Eriten commented Mar 13, 2019

Yes, that worked. For testing I've ran the following from geerlingguy/ansible-role-jenkins#28 in script console. Moving forward, I plan to put it in init.groovy.d so that this will be set up at startup.

import jenkins.model.*

def instance = Jenkins.getInstance()

final String name = "{{ jenkins_proxy_host }}"
final int port = {{ jenkins_proxy_port }}
final String userName = "{{ jenkins_proxy_user }}"
final String password = "{{ jenkins_proxy_pass }}"
final String noProxyHost = "{{ jenkins_proxy_exceptions }}"

final def pc = new hudson.ProxyConfiguration(name, port, userName, password, noProxyHost)
instance.proxy = pc
instance.save()
println "Proxy settings updated!"

@timja
Copy link
Member

timja commented Mar 13, 2019

Ok you can also do it in the configuration as code plugin,
This PR will be merged shortly and then it would look like:
https://github.com/jenkinsci/configuration-as-code-plugin/pull/769/files

jenkins:
  proxy:
    name: "proxyhost"
    port: 80
    userName: "login"
    password: "password"
    noProxyHost: "externalhost"
    testUrl: "http://google.com"

@timja timja closed this as completed Mar 13, 2019
@devantoine
Copy link

@timja Thing is: if the proxy is not set up you cannot install any plugin so you won't be able to use JCasC.

@timja
Copy link
Member

timja commented Mar 19, 2019

JCasC doesn't manage plugin installation,
not sure the relevancy of your comment,

Plugins should be installed before jenkins starts up

@jetersen
Copy link
Member

jetersen commented Mar 19, 2019

@devantoine in JCasC version 1.8 we just removed plugin installation support that was marked as a beta feature.
The full discussion can be found here:
jenkinsci/configuration-as-code-plugin#766
jenkinsci/configuration-as-code-plugin#769

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

No branches or pull requests