Skip to content
Permalink
Browse files

Merge pull request #4 from oleg-nenashev/JENKINS-49083-jep-200

[JENKINS-49083] - Make the plugin compatible with Jenkins 2.102+
  • Loading branch information...
rinrinne committed Jan 24, 2018
2 parents a4e6ff2 + d2fe349 commit cf6a6abf0312c2564af3da55ecfc193bfc449835
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin()
15 pom.xml
@@ -130,9 +130,22 @@
</build>

<scm>
<connection>scm:git:http://github.com/jenkinsci/rabbitmq-consumer-plugin.git</connection>
<connection>scm:git:https://github.com/jenkinsci/rabbitmq-consumer-plugin.git</connection>
<developerConnection>scm:git:https://github.com/jenkinsci/rabbitmq-consumer-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/rabbitmq-consumer-plugin</url>
<tag>HEAD</tag>
</scm>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
@@ -45,7 +45,7 @@
@SuppressWarnings("unused")
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalRabbitmqConfiguration.class);
private static final String[] AMQP_SCHEMES = { "amqp", "amqps" };
private final UrlValidator urlValidator = new UrlValidator(AMQP_SCHEMES, UrlValidator.ALLOW_LOCAL_URLS);
private static final UrlValidator URL_VALIDATOR = new UrlValidator(AMQP_SCHEMES, UrlValidator.ALLOW_LOCAL_URLS);

private boolean enableConsumer;
private String serviceUri;
@@ -110,7 +110,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws hudson.mode
timer.setRecurrencePeriod(watchdogPeriod);
}

if (urlValidator.isValid(serviceUri)) {
if (URL_VALIDATOR.isValid(serviceUri)) {
save();
return true;
}
@@ -251,7 +251,7 @@ public FormValidation doCheckServiceUri(@QueryParameter String value) {
return FormValidation.ok();
}

if (urlValidator.isValid(val)) {
if (URL_VALIDATOR.isValid(val)) {
return FormValidation.ok();
} else {
return FormValidation.error(Messages.InvalidURI());
@@ -275,7 +275,7 @@ public FormValidation doTestConnection(@QueryParameter("serviceUri") String serv
@QueryParameter("userName") String userName,
@QueryParameter("userPassword") Secret userPassword) throws ServletException {
String uri = StringUtils.strip(StringUtils.stripToNull(serviceUri), "/");
if (uri != null && urlValidator.isValid(uri)) {
if (uri != null && URL_VALIDATOR.isValid(uri)) {
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setUri(uri);
@@ -37,7 +37,6 @@
*
* @param seviceUri
* the service URI.
* @throws IOException if ControlRMQChannel has somthing wrong.
*/
public abstract void OnCloseCompleted(String seviceUri);

@@ -46,7 +45,6 @@
*
* @param rmqConnection
* the RabbitMQ connection.
* @throws IOException if ControlRMQChannel has somthing wrong.
*/
public static void fireOnOpen(RMQConnection rmqConnection) {
LOGGER.trace("ServerOperator", "fireOnOpen");
@@ -68,7 +66,6 @@ public static void fireOnOpen(RMQConnection rmqConnection) {
*
* @param rmqConnection
* the RabbitMQ connection.
* @throws IOException if ControlRMQChannel has somthing wrong.
*/
public static void fireOnCloseCompleted(RMQConnection rmqConnection) {
LOGGER.trace("ServerOperator", "fireOnCloseCompleted");
@@ -0,0 +1,47 @@
/*
* The MIT License
*
* Copyright (c) 2018, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.plugins.rabbitmqconsumer;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.For;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

@For(GlobalRabbitmqConfiguration.class)
public class GlobalRabbitmqConfigurationTest {

@Rule
public JenkinsRule j = new JenkinsRule();

@Test
@Issue("JENKINS-49083")
public void configRoundtrip() throws Exception {
GlobalRabbitmqConfiguration c = GlobalRabbitmqConfiguration.get();
c.setUserName("foo");
c.setUserPassword("bar");
c.save();
c.load();
}
}

0 comments on commit cf6a6ab

Please sign in to comment.
You can’t perform that action at this time.