From 7c68877e72adbb841f63a4eb68ca5e457a6cb5b8 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 15 Jan 2020 21:32:13 +0100 Subject: [PATCH] Retire zmq-event-publisher The repo has been forked and is maintained elsewhere. OpenStack does not need it anymore, so retire it. Depends-On: https://review.opendev.org/702745 Change-Id: I0787450fdc66beba7d191280b9d208ab2fc024d6 --- .gitignore | 2 - LICENSE | 202 ----------- README | 44 --- README.rst | 10 + pom.xml | 337 ------------------ run-fast | 2 - .../HudsonNotificationProperty.java | 86 ----- .../plugins/ZMQEventPublisher/Phase.java | 104 ------ .../ZMQEventPublisher/RunListenerImpl.java | 126 ------- .../ZMQEventPublisher/ZMQRunnable.java | 116 ------ .../ZMQEventPublisher/model/BuildState.java | 114 ------ .../ZMQEventPublisher/model/JobState.java | 50 --- src/main/resources/index.jelly | 3 - .../HudsonNotificationProperty/config.jelly | 9 - .../HudsonNotificationProperty/global.jelly | 12 - src/main/webapp/help-globalConfig.html | 6 - 16 files changed, 10 insertions(+), 1213 deletions(-) delete mode 100644 .gitignore delete mode 100644 LICENSE delete mode 100644 README create mode 100644 README.rst delete mode 100644 pom.xml delete mode 100755 run-fast delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java delete mode 100644 src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/JobState.java delete mode 100644 src/main/resources/index.jelly delete mode 100644 src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/config.jelly delete mode 100644 src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/global.jelly delete mode 100644 src/main/webapp/help-globalConfig.html diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 654f3f0..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -work/ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 75b5248..0000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README b/README deleted file mode 100644 index 764b72f..0000000 --- a/README +++ /dev/null @@ -1,44 +0,0 @@ -This is a Jenkins plugin that will publish Jenkins Job run events -(start, complete, finish) to a ZMQ PUB socket. By default the PUB -socket is on TCP port 8888 and no Job events will be published. -You can choose to enable event publishing for all jobs in the -Jenkins' global config or enable the plugin on a per job basis. - -This plugin uses jeromq to satisfy the dependency on ZMQ. It is -possible to use jzmq instead if you need the features that jeromq -is lacking; however, it is a pain to get jzmq built and is less -portable. If you really really want jzmq look back in the git -history and you will find the old versions of this plugin that -depended on jzmq. - -TODO: -- Avoid reading in the global config for each event if possible. -- Need to allow ZMQRunnable thread to die if something truly - unexpected happens. The RunListener should then start a new - DaemonThread to handle further events. -- Cleanup config.jelly for the non global Job config. - -This plugin borrows heavily from the Jenkins Notification Plugin -https://github.com/jenkinsci/notification-plugin. That plugin -does much of the same work and where applicable I have gone the -easy route and copied the work they have done. - -Contributing ------------- - -To browse the latest code, see: -https://git.openstack.org/cgit/openstack-infra/zmq-event-publisher/tree/ -To clone the latest code, use -`git clone https://git.openstack.org/openstack-infra/zmq-event-publisher` - -Bugs are handled at: https://storyboard.openstack.org/#!/project/750 - -Code reviews are handled by gerrit. The gerrit in -use is http://review.openstack.org - -Use `git review` to submit patches (after creating a gerrit account that -links to your launchpad account). Example:: - - # Do your commits - $ git review - # Enter your username if prompted diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..86e34d6 --- /dev/null +++ b/README.rst @@ -0,0 +1,10 @@ +This project is no longer maintained. + +The contents of this repository are still available in the Git +source code management system. To see the contents of this +repository before it reached its end of life, please check out the +previous commit with "git checkout HEAD^1". + +For any further questions, please email +openstack-discuss@lists.openstack.org or join #openstack-dev on +Freenode. diff --git a/pom.xml b/pom.xml deleted file mode 100644 index dcdcee6..0000000 --- a/pom.xml +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - 4.0.0 - - - org.jenkins-ci.plugins - plugin - 1.460 - - - org.jenkins-ci.plugins - zmq-event-publisher - hpi - ${project-version} - - Jenkins Event Publisher (via ZMQ PUB SUB) - https://wiki.jenkins-ci.org/display/JENKINS/ZMQ+Event+Publisher+Plugin - - - - Apache License, Version 2.0 - http://git.openstack.org/cgit/openstack-infra/zmq-event-publisher/tree/LICENSE - repo - - - - - - clarkb - Clark Boylan - clark.boylan@gmail.com - - - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - - - com.google.code.gson - gson - 1.4 - - - org.jeromq - jeromq - 0.2.0 - - - - - - Windows - - - windows - - - - Windows - - - - - - - repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ - - - - - - java.net-m2-repository - http://maven.jenkins-ci.org/content/repositories/releases/ - - - github-project-site - gitsite:git@github.com/jenkinsci/hello-world-plugin - - - - - ${os.name} - - UTF-8 - 1.6 - - 3.0.1 - 1.6 - 2.2 - 2.2 - 2.6 - 2.4.1 - 2.3.2 - 2.1 - 2.5 - 1.0 - 2.8 - 1.0 - 2.1.1 - 2.3.1 - 2.7 - 2.3.1 - 6.1.26 - 2.2 - 2.5 - 2.3.1 - 2.4.3 - 1.0 - 2.1 - 1.1 - 2.4.3 - 2.1.1 - 2.1.2 - 2.7.2 - 2.7.2 - 2.1.1 - 1.0-alpha-4 - 1.4 - 1.0-beta-4 - 1.5 - 1.0.5 - 2.4 - 1.2 - 2.3.1 - 2.1.0-1 - 2.0 - 2.0-beta-2 - 1.2 - 2.4 - 1.2 - 1.0-beta-3 - - - - - - - maven-clean-plugin - ${maven-clean-plugin.version} - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${compileSource} - ${compileTarget} - true - true - - - - maven-deploy-plugin - ${maven-deploy-plugin.version} - - - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - maven-install-plugin - ${maven-install-plugin.version} - - - maven-jar-plugin - ${maven-jar-plugin.version} - - - maven-release-plugin - ${maven-release-plugin.version} - - true - true - clean deploy - clean deploy - release - - - - maven-remote-resources-plugin - ${maven-remote-resources-plugin.version} - - - maven-resources-plugin - ${maven-resources-plugin.version} - - - maven-site-plugin - ${maven-site-plugin.version} - - - maven-source-plugin - ${maven-source-plugin.version} - - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - methods - true - 4 - - - - - - - maven-doap-plugin - ${maven-doap-plugin.version} - - - site - pre-site - - generate - - - - - ${project.reporting.outputDirectory}/doap.rdf - - false - - - - - maven-site-plugin - ${maven-site-plugin.version} - - - - - - - - maven-changelog-plugin - ${maven-changelog-plugin.version} - - - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - - maven-jxr-plugin - ${maven-jxr-plugin.version} - - - maven-pmd-plugin - ${maven-pmd-plugin.version} - - - maven-plugin-plugin - ${maven-plugin-plugin.version} - - - maven-project-info-reports-plugin - ${maven-project-info-reports-plugin.version} - - - - cim - distribution-management - index - issue-tracking - license - mailing-list - project-team - summary - - - - - - maven-surefire-report-plugin - ${maven-surefire-report-plugin.version} - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura-maven-plugin.version} - - - org.codehaus.mojo - findbugs-maven-plugin - ${findbugs-maven-plugin.version} - - - org.codehaus.mojo - javancss-maven-plugin - ${javancss-maven-plugin.version} - - - org.codehaus.mojo - jdepend-maven-plugin - ${jdepend-maven-plugin.version} - - - org.codehaus.mojo - taglist-maven-plugin - ${taglist-maven-plugin.version} - - - - - - diff --git a/run-fast b/run-fast deleted file mode 100755 index 4a22fcb..0000000 --- a/run-fast +++ /dev/null @@ -1,2 +0,0 @@ -rm -rf work/plugins -mvn -Dmaven.test.skip=true -DskipTests=true clean hpi:run diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java deleted file mode 100644 index b3e347e..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013 Hewlett-Packard Development Company, L.P. - * Copyright Authors of the Jenkins Notification Plugin - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jenkinsci.plugins.ZMQEventPublisher; - -import hudson.Extension; -import hudson.model.Job; -import hudson.model.JobProperty; -import hudson.model.JobPropertyDescriptor; -import hudson.model.AbstractProject; - -import net.sf.json.JSONObject; - -import org.kohsuke.stapler.DataBoundConstructor; -import org.kohsuke.stapler.StaplerRequest; - -public class HudsonNotificationProperty extends - JobProperty> { - - final public boolean enabled; - - @DataBoundConstructor - public HudsonNotificationProperty(boolean enabled) { - this.enabled = enabled; - } - - public boolean isEnabled() { - return enabled; - } - - @Override - public HudsonNotificationPropertyDescriptor getDescriptor() { - return (HudsonNotificationPropertyDescriptor) super.getDescriptor(); - } - - @Extension - public static final class HudsonNotificationPropertyDescriptor extends JobPropertyDescriptor { - - private boolean globallyEnabled; - private int port; - - public HudsonNotificationPropertyDescriptor() { - globallyEnabled = false; - port = 8888; - load(); - } - - @Override - public boolean isApplicable(@SuppressWarnings("rawtypes") Class jobType) { - return true; - } - - public String getDisplayName() { - return "Jenkins ZMQ Event Publisher"; - } - - @Override - public boolean configure(StaplerRequest staplerRequest, JSONObject json) throws FormException { - globallyEnabled = json.getBoolean("globallyEnabled"); - port = json.getInt("port"); - save(); - return true; - } - - public boolean isGloballyEnabled() { - return globallyEnabled; - } - - public int getPort() { - return port; - } - } -} diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java deleted file mode 100644 index fe36f65..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2013 Hewlett-Packard Development Company, L.P. - * Copyright Authors of the Jenkins Notification Plugin - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jenkinsci.plugins.ZMQEventPublisher; - -import hudson.EnvVars; -import hudson.model.AbstractBuild; -import hudson.model.Job; -import hudson.model.ParameterValue; -import hudson.model.ParametersAction; -import hudson.model.Run; -import hudson.model.Executor; -import hudson.model.Computer; -import hudson.model.Node; -import hudson.model.TaskListener; -import jenkins.model.Jenkins; - -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import org.jenkinsci.plugins.ZMQEventPublisher.model.BuildState; -import org.jenkinsci.plugins.ZMQEventPublisher.model.JobState; - -public enum Phase { - STARTED, COMPLETED, FINISHED; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public String handlePhase(Run run, String status, String masterName, TaskListener listener) { - Jenkins jenkins = Jenkins.getInstance(); - HudsonNotificationProperty property = (HudsonNotificationProperty) - run.getParent().getProperty(HudsonNotificationProperty.class); - HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = - (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) - jenkins.getDescriptor(HudsonNotificationProperty.class); - if ((property != null && property.isEnabled()) || - (globalProperty != null && globalProperty.isGloballyEnabled())) { - return buildMessage(run.getParent(), run, status, masterName); - } - return null; - } - - private Gson gson = new GsonBuilder().setFieldNamingPolicy( - FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); - - private String buildMessage(Job job, Run run, String status, String masterName) { - JobState jobState = new JobState(); - jobState.setName(job.getName()); - jobState.setUrl(job.getUrl()); - BuildState buildState = new BuildState(); - buildState.setNumber(run.number); - buildState.setUrl(run.getUrl()); - buildState.setPhase(this); - buildState.setStatus(status); - - Jenkins jenkins = Jenkins.getInstance(); - String rootUrl = jenkins.getRootUrl(); - if (rootUrl != null) { - buildState.setFullUrl(rootUrl + run.getUrl()); - } - if (masterName != null) { - buildState.setHostName(masterName); - } - - Executor executor = run.getExecutor(); - if (executor != null) { - Computer computer = executor.getOwner(); - if (computer != null) { - buildState.setNodeName(computer.getName()); - Node node = computer.getNode(); - if (node != null) { - buildState.setNodeDescription(node.getNodeDescription()); - } - } - } - - jobState.setBuild(buildState); - - ParametersAction paramsAction = run.getAction(ParametersAction.class); - if (paramsAction != null && run instanceof AbstractBuild) { - AbstractBuild build = (AbstractBuild) run; - EnvVars env = new EnvVars(); - for (ParameterValue value : paramsAction.getParameters()) - if (!value.isSensitive()) - value.buildEnvVars(build, env); - buildState.setParameters(env); - } - - return gson.toJson(jobState); - } -} diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java deleted file mode 100644 index e630cc5..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2013 Hewlett-Packard Development Company, L.P. - * Copyright Authors of the Jenkins Notification Plugin - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package org.jenkinsci.plugins.ZMQEventPublisher; - -import hudson.Extension; -import hudson.model.Computer; -import hudson.model.Result; -import hudson.model.Run; -import hudson.model.TaskListener; -import hudson.model.listeners.RunListener; -import hudson.util.DaemonThreadFactory; - -import jenkins.model.Jenkins; - -import java.net.InetAddress; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.logging.Level; -import java.util.logging.Logger; - -/* - * Listener to publish Jenkins build events through ZMQ - */ -@Extension -public class RunListenerImpl extends RunListener { - public static final Logger LOGGER = - Logger.getLogger(RunListenerImpl.class.getName()); - private final LinkedBlockingQueue queue = - new LinkedBlockingQueue(queueLength); - // ZMQ has a high water mark of 1000 events. - private static final int queueLength = 1024; - private static final DaemonThreadFactory threadFactory = - new DaemonThreadFactory(); - private ZMQRunnable ZMQRunner; - private Thread thread; - private String masterName; - - public RunListenerImpl() { - super(Run.class); - ZMQRunner = new ZMQRunnable(queue); - thread = threadFactory.newThread(ZMQRunner); - thread.start(); - - Computer master = null; - String hostname = null; - // query Jenkins for master's name - try { - master = Jenkins.getInstance().getComputer(""); - if (master != null) { - hostname = master.getHostName(); - } - else { - // master node may not be enabled so get masterName from system - hostname = java.net.InetAddress.getLocalHost().getHostName(); - } - } catch (Exception e) { - } - masterName = hostname; - } - - @Override - public void onCompleted(Run build, TaskListener listener) { - String event = "onCompleted"; - String json = Phase.COMPLETED.handlePhase(build, getStatus(build), masterName, listener); - sendEvent(event, json); - } - - /* Currently not emitting onDeleted events. This should be fixed. - @Override - public void onDeleted(Run build) { - String update = String.format("onDeleted"); - bindSocket(build); - publisher.send(update.getBytes(), 0); - } - */ - - @Override - public void onFinalized(Run build) { - String event = "onFinalized"; - String json = Phase.FINISHED.handlePhase(build, getStatus(build), masterName, TaskListener.NULL); - sendEvent(event, json); - } - - @Override - public void onStarted(Run build, TaskListener listener) { - String event = "onStarted"; - String json = Phase.STARTED.handlePhase(build, getStatus(build), masterName, listener); - sendEvent(event, json); - } - - private void sendEvent(String event, String json) { - if (json != null) { - event = event + " " + json; - // Offer the event. If the queue is full this will not block. - // We may drop events but this should prevent starvation in - // the calling Jenkins threads. - if (!queue.offer(event)) { - LOGGER.log(Level.INFO, - "Unable to add event to ZMQ queue."); - } - } - } - - private String getStatus(Run r) { - Result result = r.getResult(); - String status = null; - if (result != null) { - status = result.toString(); - } - return status; - } -} diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java deleted file mode 100644 index 7e54276..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/ZMQRunnable.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2013 Hewlett-Packard Development Company, L.P. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package org.jenkinsci.plugins.ZMQEventPublisher; - -import jenkins.model.Jenkins; - -import java.util.concurrent.LinkedBlockingQueue; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jeromq.ZMQ; -import org.jeromq.ZMQException; - -public class ZMQRunnable implements Runnable { - public static final Logger LOGGER = Logger.getLogger(ZMQRunnable.class.getName()); - - private static final String bind_addr = "tcp://*:%d"; - private int port; - - private final LinkedBlockingQueue queue; - private final ZMQ.Context context; - private ZMQ.Socket publisher; - - public ZMQRunnable(LinkedBlockingQueue queue) { - this.queue = queue; - context = ZMQ.context(1); - bindSocket(); - } - - private int getPort() { - Jenkins jenkins = Jenkins.getInstance(); - HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = - (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) - jenkins.getDescriptor(HudsonNotificationProperty.class); - if (globalProperty != null) { - return globalProperty.getPort(); - } - return 8888; - } - - private void bindSocket() { - int tmpPort = getPort(); - if (publisher == null) { - port = tmpPort; - LOGGER.log(Level.INFO, - String.format("Binding ZMQ PUB to port %d", port)); - publisher = bindSocket(port); - } - else if (tmpPort != port) { - LOGGER.log(Level.INFO, - String.format("Changing ZMQ PUB port from %d to %d", port, tmpPort)); - try { - publisher.close(); - } catch (ZMQException e) { - /* Let the garbage collector sort out cleanup */ - LOGGER.log(Level.INFO, - "Unable to close ZMQ PUB socket. " + e.toString(), e); - } - port = tmpPort; - publisher = bindSocket(port); - } - } - - private ZMQ.Socket bindSocket(int port) { - ZMQ.Socket socket; - try { - socket = context.socket(ZMQ.PUB); - socket.bind(String.format(bind_addr, port)); - } catch (ZMQException e) { - LOGGER.log(Level.SEVERE, - "Unable to bind ZMQ PUB socket. " + e.toString(), e); - socket = null; - } - return socket; - } - - public void run() { - String event; - while(true) { - try { - event = queue.take(); - bindSocket(); - if (publisher != null) { - try { - LOGGER.log(Level.FINE, "Publishing ZMQ event: " + event); - publisher.send(event.getBytes(), 0); - } catch (ZMQException e) { - LOGGER.log(Level.INFO, - "Unable to send event. " + e.toString(), e); - } - } else { - LOGGER.log(Level.WARNING, "ZMQ Publisher is NULL"); - } - } - // Catch all exceptions so that this thread does not die. - catch (Exception e) { - LOGGER.log(Level.SEVERE, - "Unhandled exception publishing ZMQ events " + e.toString(), e); - } - } - } -} diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java deleted file mode 100644 index 4413a63..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/BuildState.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright Authors of the Jenkins Notification Plugin - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jenkinsci.plugins.ZMQEventPublisher.model; - -import org.jenkinsci.plugins.ZMQEventPublisher.Phase; - -import java.util.Map; - -public class BuildState { - - private String fullUrl; - - private int number; - - private Phase phase; - - private String status; - - private String url; - - private Map parameters; - - private String nodeName; - - private String nodeDescription; - - private String hostName; - - public int getNumber() { - return number; - } - - public void setNumber(int number) { - this.number = number; - } - - public Phase getPhase() { - return phase; - } - - public void setPhase(Phase phase) { - this.phase = phase; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getFullUrl() { - return fullUrl; - } - - public void setFullUrl(String fullUrl) { - this.fullUrl = fullUrl; - } - - public Map getParameters() { - return parameters; - } - - public void setParameters(Map params) { - this.parameters = params; - } - - public String getNodeName() { - return nodeName; - } - - public void setNodeName(String nodeName) { - this.nodeName = nodeName; - } - - public String getNodeDescription() { - return nodeDescription; - } - - public void setNodeDescription(String nodeDescription) { - this.nodeDescription = nodeDescription; - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } -} diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/JobState.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/JobState.java deleted file mode 100644 index 4986f9c..0000000 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/model/JobState.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright Authors of the Jenkins Notification Plugin - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jenkinsci.plugins.ZMQEventPublisher.model; - -public class JobState { - - private String name; - - private String url; - - private BuildState build; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public BuildState getBuild() { - return build; - } - - public void setBuild(BuildState build) { - this.build = build; - } -} diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly deleted file mode 100644 index e53f0ac..0000000 --- a/src/main/resources/index.jelly +++ /dev/null @@ -1,3 +0,0 @@ -
- This plugin publishes Jenkins build events in JSON as a ZMQ Publisher. -
diff --git a/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/config.jelly b/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/config.jelly deleted file mode 100644 index 943774f..0000000 --- a/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/config.jelly +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/global.jelly b/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/global.jelly deleted file mode 100644 index ba4a638..0000000 --- a/src/main/resources/org/jenkinsci/plugins/ZMQEventPublisher/HudsonNotificationProperty/global.jelly +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/src/main/webapp/help-globalConfig.html b/src/main/webapp/help-globalConfig.html deleted file mode 100644 index b664584..0000000 --- a/src/main/webapp/help-globalConfig.html +++ /dev/null @@ -1,6 +0,0 @@ -
-

- Plugin that will publish Jenkins Job run events on the specified port - via ZMQ PUB SUB. -

-