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

Feat/Support for local plugin proxy #277

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

rockleez
Copy link
Contributor

Summary
This PR addresses JENKINS-61989 and implements proxy support on the Office365ConnectorPlugin itself instead of utilizing the Jenkins global proxy config. In my case i would have to add multiple no proxy hosts to achieve the existing stability of the Jenkins server.

Implementation

  • Updated global.jelly to support new fields
  • Added a Proxy class that contains proxy fields
  • Updated Webook to support new fields and implemented the proxy to be initialized in the constructor

image

Testing
Unit Tests

  • All existing tests that were affected have been updated to mock Webhook.DescriptorImpl so that the proxy could be intialized
  • Added unit tests for Proxy class

Integration Tests

  • Tested using mvn:hpi run and also built a snapshot and deployed to a secondary local Jenkins running on linux

  • Created test jobs for pipeline and freestyle builds
    image

  • Blocked incoming connections on the firewall
    image

  • Used Fiddler Classic to act as a proxy and recorded traffic incoming via the proxy and messages appearing in MS Teams.
    image
    image

  • Regression testing confirmed that without the with the proxy not configured, the proxy configured in the pipeline, and the proxy configured globally, the plugin continues to function as expected.

Please roll this into a new release once approved

pom.xml Outdated Show resolved Hide resolved
@rockleez
Copy link
Contributor Author

@damianszczepanik on a similar not I've noticed that the proxy config only takes effect when the job config is opened and saved even with no changes being made. Is this normal behavior due to the architecture of Jenkins?

Example.

  • I have Freestyle Job 1 and Pipeline Job 1 (with an additional step to send a message)
  • Both jobs have the wehbook configured with some default notifications selected
  • Running the jobs both work as expected and messages are sent to the teams channel
  • Add proxy config
  • Running the jobs again, the proxy config is not used except in Pipeline job 1 in the office365ConnectorSend message
  • Open both jobs and click save without changing anything
  • Config is now refreshed
    • Running the jobs both work as expected and messages are sent to the teams channel this time via the proxy

@rockleez
Copy link
Contributor Author

@damianszczepanik do you have an eta on when this review can be completed and merged into a release. Thanks

@damianszczepanik
Copy link
Member

Yes, saving updates job

@rockleez rockleez requested review from damianszczepanik and deronek and removed request for damianszczepanik and deronek November 7, 2022 21:57
}

@DataBoundSetter
public void setIp(String ip) {
Copy link
Member

Choose a reason for hiding this comment

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

IP or address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

settled on using the term host

}

@Nonnull
public String getPort() {
Copy link
Member

Choose a reason for hiding this comment

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

Reorder and put port together with ip/address

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -14,7 +14,7 @@
This section defines for which build statuses the notification is sent.
</f:description>

<f:entry title="Notify Build Start" field="startNotification">
<f:entry title="Notify Build Start" field="startNotification" >
Copy link
Member

Choose a reason for hiding this comment

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

needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -7,5 +7,25 @@
<f:entry title="Name" field="globalName">
<f:textbox/>
</f:entry>
<f:advanced>
<f:section title="Proxy Config">
Copy link
Member

Choose a reason for hiding this comment

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

Configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1 @@
<div align="help">The IP address of the proxy server</div>
Copy link
Member

Choose a reason for hiding this comment

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

Would the proxy.local.dev be valid value It does not look like IP address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the description

@@ -1,16 +1,19 @@
package jenkins.plugins.office365connector.workflow;

import static org.assertj.core.api.Assertions.assertThat;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.*;
Copy link
Member

Choose a reason for hiding this comment

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

Prefer not to use asterix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

Choose a reason for hiding this comment

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

not really, now this import is redundant


when(jenkins.getDescriptorOrDie(Webhook.class)).thenReturn(mockDescriptor);
when(Jenkins.get()).thenReturn(jenkins);
}
Copy link
Member

Choose a reason for hiding this comment

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

empty line between methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be resolved


when(jenkins.getDescriptorOrDie(Webhook.class)).thenReturn(mockDescriptor);
when(Jenkins.get()).thenReturn(jenkins);
}
@Test
Copy link
Member

Choose a reason for hiding this comment

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

Rebase the code and fix above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebased

@damianszczepanik
Copy link
Member

Github says that this still has some conflicts

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.

3 participants