├── README ├── src └── main │ ├── resources │ ├── index.jelly │ └── ru │ │ └── snowleos │ │ └── jenkins │ │ └── anchorchain │ │ └── LinksPublisher │ │ ├── global.jelly │ │ ├── config.jelly │ │ └── help-name.html │ ├── webapp │ └── help-globalConfig.html │ └── java │ └── ru │ └── snowleos │ └── jenkins │ └── anchorchain │ └── LinksPublisher.java ├── LICENSE.txt └── pom.xml /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 | 4 |
5 | Adds some links to the sidebar at every build. The data are obtained from 6 | a user selected file in a working directory. 7 |
8 | -------------------------------------------------------------------------------- /src/main/webapp/help-globalConfig.html: -------------------------------------------------------------------------------- 1 |
2 | This HTML fragment will be injected into the configuration screen 3 | when the user clicks the 'help' icon. See global.jelly for how the 4 | form decides which page to load. 5 | You can have any HTML fragment here. 6 |
7 | -------------------------------------------------------------------------------- /src/main/resources/ru/snowleos/jenkins/anchorchain/LinksPublisher/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/ru/snowleos/jenkins/anchorchain/LinksPublisher/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/ru/snowleos/jenkins/anchorchain/LinksPublisher/help-name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
The plugin adds some links to the sidebar at every build. The data are obtained from 10 | a user selected file in a working directory. The structure of the file is 11 | as follows: 12 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.jenkins-ci.plugins 5 | plugin 6 | 1.399 7 | 8 | 9 | AnchorChain 10 | 1.1-SNAPSHOT 11 | hpi 12 | 13 | 14 | MIT License 15 | http://opensource.org/licenses/MIT 16 | 17 | 18 | AnchorChain 19 | Adds links from a text file to sidebar on each build 20 | https://wiki.jenkins-ci.org/display/JENKINS/AnchorChain+plugin 21 | 22 | 23 | direvius 24 | Alexey Lavrenuke 25 | direvius@gmail.com 26 | 27 | 28 | 29 | 30 | scm:git:ssh://github.com/jenkinsci/anchor-chain-plugin.git 31 | scm:git:ssh://git@github.com/jenkinsci/anchor-chain-plugin.git 32 | https://github.com/jenkinsci/anchor-chain-plugin 33 | 34 | 35 | 36 | 37 | 38 | repo.jenkins-ci.org 39 | http://repo.jenkins-ci.org/public/ 40 | 41 | 42 | 43 | 44 | 45 | repo.jenkins-ci.org 46 | http://repo.jenkins-ci.org/public/ 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/java/ru/snowleos/jenkins/anchorchain/LinksPublisher.java: -------------------------------------------------------------------------------- 1 | package ru.snowleos.jenkins.anchorchain; 2 | import hudson.Extension; 3 | import hudson.Launcher; 4 | import hudson.FilePath; 5 | import hudson.tasks.BuildStepMonitor; 6 | import hudson.model.AbstractBuild; 7 | import hudson.model.AbstractProject; 8 | import hudson.model.BuildListener; 9 | import hudson.model.Action; 10 | import hudson.model.ProminentProjectAction; 11 | import hudson.tasks.BuildStepDescriptor; 12 | import hudson.tasks.Builder; 13 | import hudson.tasks.Notifier; 14 | import hudson.tasks.Publisher; 15 | import hudson.util.FormValidation; 16 | import org.kohsuke.stapler.DataBoundConstructor; 17 | import org.kohsuke.stapler.StaplerRequest; 18 | 19 | import java.io.IOException; 20 | import javax.servlet.ServletException; 21 | import org.kohsuke.stapler.QueryParameter; 22 | 23 | public class LinksPublisher extends Notifier { 24 | 25 | private final String name; 26 | 27 | // Fields in config.jelly must match the parameter names in the "DataBoundConstructor" 28 | @DataBoundConstructor 29 | public LinksPublisher(String name) { 30 | this.name = name; 31 | } 32 | 33 | /** 34 | * We'll use this from the config.jelly. 35 | */ 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | @Override 41 | public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { 42 | if(name.isEmpty()){ 43 | listener.getLogger().println("Anchor chain: filename is not set."); 44 | return true; 45 | } 46 | try { 47 | String [] lines = 48 | (new FilePath(build.getWorkspace(), name) 49 | .readToString().split("\\r?\\n")); 50 | for(String line : lines){ 51 | listener.getLogger().println(line); 52 | String[] fields = line.split("\\t+"); 53 | if(fields.length >= 2){ 54 | build.addAction(new LinkAction(fields)); 55 | } else listener.getLogger().println("Anchor chain: could not parse line. Need 3 fields: name, url, icon. Got: "+line); 56 | } 57 | } catch (IOException ex) { 58 | listener.getLogger().println("Anchor chain: could not read file with links: "+ex.getLocalizedMessage()); 59 | } 60 | return true; 61 | } 62 | 63 | 64 | public BuildStepMonitor getRequiredMonitorService() { 65 | return BuildStepMonitor.NONE; 66 | } 67 | 68 | public static final class LinkAction implements Action, ProminentProjectAction{ 69 | private final String name; 70 | private final String url; 71 | private final String icon; 72 | 73 | public LinkAction(String [] params){ 74 | this.name = params[0]; 75 | this.url = params[1]; 76 | if(params.length < 3) 77 | { 78 | this.icon = "graph.gif"; 79 | } 80 | else this.icon = params[2]; 81 | } 82 | public String getIconFileName() { 83 | return icon; 84 | } 85 | 86 | 87 | public String getDisplayName() { 88 | return name; 89 | } 90 | 91 | public String getUrlName() { 92 | return url; 93 | } 94 | 95 | } 96 | // Overridden for better type safety. 97 | // If your plugin doesn't really define any property on Descriptor, 98 | // you don't have to do this. 99 | @Override 100 | public DescriptorImpl getDescriptor() { 101 | return (DescriptorImpl)super.getDescriptor(); 102 | } 103 | @Extension // This indicates to Jenkins that this is an implementation of an extension point. 104 | public static final class DescriptorImpl extends BuildStepDescriptor { 105 | 106 | 107 | public boolean isApplicable(Class aClass) { 108 | // Indicates that this builder can be used with all kinds of project types 109 | return true; 110 | } 111 | 112 | public FormValidation doCheckName(@QueryParameter String value) 113 | throws IOException, ServletException { 114 | if (value.length() == 0) 115 | return FormValidation.error("Please set a filename"); 116 | if (value.length() < 4) 117 | return FormValidation.warning("Isn't the name too short?"); 118 | return FormValidation.ok(); 119 | } 120 | 121 | /** 122 | * This human readable name is used in the configuration screen. 123 | */ 124 | public String getDisplayName() { 125 | return "Anchor Chain"; 126 | } 127 | 128 | } 129 | 130 | } 131 | 132 | --------------------------------------------------------------------------------