Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cowboyd/jenkins-plugin
base: master
...
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 16 commits
  • 28 files changed
  • 1 commit comment
  • 2 contributors
Showing with 2 additions and 1,092 deletions.
  1. +0 −4 Gemfile
  2. +2 −74 README.md
  3. +0 −6 Rakefile
  4. +0 −5 bin/jpi
  5. +0 −18 features/create-new-plugin.feature
  6. +0 −7 features/support/create_new_plugin_steps.rb
  7. +0 −49 features/support/directory_structure.rb
  8. +0 −20 features/support/work.rb
  9. +0 −30 jenkins-plugin.gemspec
  10. +0 −39 lib/jenkins/jenkins-ci.org/credential.rb
  11. +0 −66 lib/jenkins/plugin/cli.rb
  12. +0 −54 lib/jenkins/plugin/cli/formatting.rb
  13. +0 −27 lib/jenkins/plugin/cli/generate.rb
  14. +0 −39 lib/jenkins/plugin/cli/new.rb
  15. +0 −4 lib/jenkins/plugin/cli/templates/Gemfile.tt
  16. +0 −25 lib/jenkins/plugin/cli/templates/build_step.tt
  17. +0 −28 lib/jenkins/plugin/cli/templates/pluginspec.tt
  18. +0 −30 lib/jenkins/plugin/tools/bundle.rb
  19. +0 −107 lib/jenkins/plugin/tools/hpi.rb
  20. +0 −29 lib/jenkins/plugin/tools/loadpath.rb
  21. +0 −80 lib/jenkins/plugin/tools/manifest.rb
  22. +0 −60 lib/jenkins/plugin/tools/package.rb
  23. +0 −70 lib/jenkins/plugin/tools/release.rb
  24. +0 −61 lib/jenkins/plugin/tools/resolver.rb
  25. +0 −49 lib/jenkins/plugin/tools/server.rb
  26. +0 −54 lib/jenkins/plugin/tools/templates/release-pom.xml.erb
  27. +0 −5 lib/jenkins/plugin/version.rb
  28. +0 −52 lib/jenkins/rake.rb
View
4 Gemfile
@@ -1,4 +0,0 @@
-source "http://rubygems.org"
-
-# Specify your gem's dependencies in jenkins-plugins.gemspec
-gemspec
View
76 README.md
@@ -1,76 +1,4 @@
-# Jenkins plugins
-
-Provide the facility to create, develop and release extensions for [Jenkins](http://jenkins-ci.org) with nothing but knowledge of the language, tools and best practices of the Ruby community.
-
-[read more](http://blog.thefrontside.net/2011/05/12/what-it-take-to-bring-ruby-to-jenkins)...
-
-# Get started
-
-Using JRuby, install the plugin tools
-
- $ gem install jenkins-plugin
-
-The gem provides the `jpi` executeable
-
- $ jpi -h
-
- jpi- tools to create, build, develop and release Jenkins plugins
-
- Usage: jpi command [arguments] [options]
-
- Commands:
- jpi help [COMMAND] # get help for COMMAND, or for jpi itself
- jpi new NAME # create a new plugin called NAME
- jpi generate # generate code for extensions points
- jpi build # build plugin into .hpi file suitable for distribution
- jpi server # run a test server with plugin
- jpi version # show jpi version information
-
-The first thing you'll probably want to do is create a new ruby plugin.
-
- $ jpi new one-great-plugin
- create one-great-plugin/Gemfile
- create one-great-plugin/one-great-plugin.pluginspec
-
-This will create a minimal plugin project structure, to which you can add later.
-Once you have your plugin created, you can run a server with it loaded
-
- $ cd one-great-plugin
- $ jpi server
-
- Listening for transport dt_socket at address: 8000
- webroot: System.getProperty("JENKINS_HOME")
- [Winstone 2011/09/19 12:01:36] - Beginning extraction from war file
- [Winstone 2011/09/19 12:01:37] - HTTP Listener started: port=8080
- [Winstone 2011/09/19 12:01:37] - AJP13 Listener started: port=8009
- [Winstone 2011/09/19 12:01:37] - Winstone Servlet Engine v0.9.10 running: controlPort=disabled
- Sep 19, 2011 12:01:37 PM jenkins.model.Jenkins$6 onAttained
- INFO: Started initialization
- Sep 19, 2011 12:01:38 PM hudson.PluginManager$1$3$1 isDuplicate
- Sep 19, 2011 12:01:39 PM jenkins.model.Jenkins$6 onAttained
- INFO: Listed all plugins
- Sep 19, 2011 12:01:39 PM ruby.RubyRuntimePlugin start
- INFO: Injecting JRuby into XStream
- Sep 19, 2011 12:01:49 PM jenkins.model.Jenkins$6 onAttained
- INFO: Prepared all plugins
- Sep 19, 2011 12:01:49 PM jenkins.model.Jenkins$6 onAttained
- INFO: Started all plugins
- Sep 19, 2011 12:01:49 PM jenkins.model.Jenkins$6 onAttained
- INFO: Augmented all extensions
- Sep 19, 2011 12:01:49 PM jenkins.model.Jenkins$6 onAttained
- INFO: Loaded all jobs
- Sep 19, 2011 12:01:51 PM jenkins.model.Jenkins$6 onAttained
- INFO: Completed initialization
- Sep 19, 2011 12:01:51 PM hudson.TcpSlaveAgentListener <init>
- INFO: JNLP slave agent listener started on TCP port 52262
- Sep 19, 2011 12:02:01 PM hudson.WebAppMain$2 run
- INFO: Jenkins is fully up and running
-
-Of course, this plugin isn't actually doing anything because we haven't defined any extension
-points. Let's go ahead and create one of the most common extension points: a `Builder`
-
- $ jpi generate builder logging
- TODO: implement generators
-
+# This repository is no longer maintained, and will be removed at some point.
+All jenkins related ruby code [has been moved](https://github.com/jenkinsci/jenkins.rb)
View
6 Rakefile
@@ -1,6 +0,0 @@
-require 'bundler'
-Bundler::GemHelper.install_tasks
-
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec)
-
View
5 bin/jpi
@@ -1,5 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'jenkins/plugin/cli'
-
-Jenkins::Plugin::CLI.start ARGV
View
18 features/create-new-plugin.feature
@@ -1,18 +0,0 @@
-
-Feature: Generating a new Jenkins Ruby Plugin
-
-Creating a new Ruby plugin for Jenkins needs to be as simple as running a single command
-that will generate a project skeleton. This skeleton will come complete with git repository and all
-the goodies that you need to do your plugin develompent.
-
-Scenario: The directory skeleton is generated
- When I run "jpi new newplugin"
- # Then I should see this structure
- # """
- # [-] newplugin
- # | [+] .git
- # | .gitignore
- # | Gemfile
- # | Rakefile
- # | newplugin.pluginspec
- # """
View
7 features/support/create_new_plugin_steps.rb
@@ -1,7 +0,0 @@
-When /^I run "([^"]*)"$/ do |cmd|
- run cmd
-end
-
-Then /^I should see this structure$/ do |structure|
- fail "no match" unless DirectoryStructure.new(structure).matches? work_dir
-end
View
49 features/support/directory_structure.rb
@@ -1,49 +0,0 @@
-
-class DirectoryStructure
- def initialize(structure)
-
- @root = context = DirChild.new('.')
-
- structure.each_line do |line|
- if line =~ /(\[[-+]\]|\|)?\s+(\.?\w+)$/
- op, name = $1, $2
- case op
- when "[+]"
- context.add(DirChild.new name)
- when "[-]"
- new_context = DirChild.new name
- context.add(new_context)
- context = new_context
- when "|"
- context.add(FileChild.new name)
- end
- end
- end
- end
-
- def matches?(dir)
- @root.matches?(dir)
- end
-
- Entry = Struct.new(:name)
-
- class DirChild < Entry
- def initialize(name)
- super(name)
- @entries = []
- end
-
- def add(entry)
- @entries << entries
- end
-
- def matches?(realdir)
- entries = Dir.new(realdir).entries
- !@entries.detect {|e| !entries.map{|e| File.basename(e)}.member?(e)}
- end
- end
-
- class FileChild < Entry
-
- end
-end
View
20 features/support/work.rb
@@ -1,20 +0,0 @@
-module Work
- def run cmd
- Dir.chdir(work_dir) do
- root = Pathname(__FILE__).join('..', '..', '..')
- full_cmd = "ruby -rubygems -I #{root.join('lib')} -S #{root.join('bin',cmd)}"
- system(full_cmd) or fail "failed to run command #{cmd}"
- end
- end
-
- def work_dir
- @work_dir ||= File.expand_path("tmp/work")
- end
-end
-
-Before do
- FileUtils.rm_rf work_dir
- FileUtils.mkdir_p work_dir
-end
-
-World(Work)
View
30 jenkins-plugin.gemspec
@@ -1,30 +0,0 @@
-# -*- encoding: utf-8 -*-
-$:.push File.expand_path("../lib", __FILE__)
-require "jenkins/plugin/version"
-
-Gem::Specification.new do |s|
- s.name = "jenkins-plugin"
- s.version = Jenkins::Plugin::VERSION
- s.platform = Gem::Platform::RUBY
- s.authors = ["Charles Lowell"]
- s.email = ["cowboyd@thefrontside.net"]
- s.homepage = "http://github.com/cowboyd/jenkins-plugin"
- s.summary = %q{Tools for creating and building Jenkins Ruby plugins}
- s.description = %q{Allows you to generate a new Ruby plugin project, build it, test it in Jenkins and release it to the Jenkins Update Center.}
-
- s.rubyforge_project = "jenkins-plugin"
-
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.require_paths = ["lib"]
-
- s.add_dependency "rubyzip"
- s.add_dependency "thor"
- s.add_dependency "jenkins-war", ">= 1.427"
- s.add_dependency "bundler", "~> 1.1.rc"
- s.add_dependency "jenkins-plugin-runtime", "~> 0.1.13"
-
- s.add_development_dependency "rspec", "~> 2.0"
- s.add_development_dependency "cucumber", "~> 1.0"
-end
View
39 lib/jenkins/jenkins-ci.org/credential.rb
@@ -1,39 +0,0 @@
-module Jenkins
- class CiOrg
- # credential to access jenkins-ci.org
- # TODO: move it elsewhere
- class Credential
- CREDENTIAL = File.expand_path("~/.jenkins-ci.org")
-
- def initialize
- @props = {}
-
- if File.exists?(CREDENTIAL) then
- File.open(CREDENTIAL,'r') do |f|
- f.each_line do |l|
- if l[0]=='#' then
- return # comment
- end
-
- k,v = l.split("=",2)
- @props[k]=v.strip
- end
- end
- end
- end
-
- # do we already have the credential?
- def has_credential?
- @props["userName"] && @props["password"]
- end
-
- def user_name
- @props["userName"]
- end
-
- def password
- @props["password"]
- end
- end
- end
-end
View
66 lib/jenkins/plugin/cli.rb
@@ -1,66 +0,0 @@
-
-require 'thor'
-require 'jenkins/plugin/specification'
-require 'jenkins/plugin/cli/formatting'
-require 'jenkins/plugin/cli/new'
-require 'jenkins/plugin/cli/generate'
-
-
-module Jenkins
- class Plugin
- class CLI < Thor
- extend Formatting
-
- register New, "new", "new NAME", "create a new plugin called NAME"
- register Generate, "generate", "generate [options] [arguments]", "add new classes/templates and views to your project"
- map "g" => "generate"
-
-
- desc "build", "build plugin into .hpi file suitable for distribution"
- def build
- require 'jenkins/plugin/tools/package'
- pkg = Tools::Package.new(spec, "pkg")
- pkg.build
- pkg
- end
-
- desc "server", "run a test server with plugin"
- method_option :home, :desc => "set server work directory", :default => 'work'
- method_option :port, :desc => "server http port (currently ignored)", :default => 8080
- method_option :war, :desc => "specify a custom jenkins.war to run the plugin with"
- def server
- require 'jenkins/plugin/tools/server'
- server = Tools::Server.new(spec, options[:home], options[:war])
- server.run!
- end
- map "s" => "server"
-
- desc "release", "release to jenkins-ci.org"
- method_option :release, :desc => "deploy as a release (as opposed to a snapshot)", :type => :boolean
- def release
- require 'jenkins/plugin/tools/release'
-
- Tools::Release.new(spec,build().file_name, !options[:release]).run
- end
-
- desc "version", "show jpi version information"
- def version
- require 'jenkins/plugin/version'
- shell.say Jenkins::Plugin::VERSION
- end
- map ["-v","--version"] => "version"
-
- desc "help [COMMAND]", "get help for COMMAND, or for jpi itself"
- def help(command = nil)
- super
- end
-
- private
-
- def spec
- Specification.find!
- end
-
- end
- end
-end
View
54 lib/jenkins/plugin/cli/formatting.rb
@@ -1,54 +0,0 @@
-
-module Jenkins
- class Plugin
- class CLI < Thor
- module Formatting
- def task_help(shell, task_name)
- meth = normalize_task_name(task_name)
- task = all_tasks[meth]
- handle_no_task_error(meth) unless task
-
- shell.say "usage: #{banner(task)}"
- shell.say
- class_options_help(shell, nil => task.options.map { |_, o| o })
- end
-
-
- def print_options(shell, options, grp = nil)
- return if options.empty?
- table = options.map do |option|
- prototype = if option.default
- " [#{option.default}]"
- elsif option.type == :boolean
- ""
- elsif option.required?
- " #{option.banner}"
- else
- " [#{option.banner}]"
- end
- aliases = option.aliases.empty? ? "" : option.aliases.join(" ") + ","
- [aliases, "--#{option.name}#{prototype}", "\t",option.description]
- end
- shell.print_table(table, :ident => 2)
- shell.say
- end
-
- def help(shell, task)
- list = printable_tasks
- print shell.set_color("jpi", :black, true)
- shell.say <<-USEAGE
- - tools to create, build, develop and release Jenkins plugins
-
-Usage: jpi command [arguments] [options]
-
-USEAGE
-
- shell.say "Commands:"
- shell.print_table(list, :ident => 2, :truncate => true)
- shell.say
- class_options_help(shell)
- end
- end
- end
- end
-end
View
27 lib/jenkins/plugin/cli/generate.rb
@@ -1,27 +0,0 @@
-
-module Jenkins
- class Plugin
- class CLI
- class Generate < Thor
- include Thor::Actions
-
- source_root File.dirname(__FILE__)
-
- argument :name
-
- desc "publisher", "publisher NAME", :desc => "generate a publish step definition"
- def publisher
- @step_class = "Publisher"
- template('templates/build_step.tt', "models/#{name.downcase}_publisher.rb")
- end
-
- desc "builder", "builder NAME", :desc => "generate a build step definition"
- def builder
- @step_class = "Builder"
- template('templates/build_step.tt', "models/#{name.downcase}_builder.rb")
- end
-
- end
- end
- end
-end
View
39 lib/jenkins/plugin/cli/new.rb
@@ -1,39 +0,0 @@
-
-require 'thor/group'
-
-module Jenkins
- class Plugin
- class CLI
- class New < Thor::Group
- include Thor::Actions
-
- source_root File.dirname(__FILE__)
-
- argument :name
-
- def create_gemfile
- template('templates/Gemfile.tt', "#{name}/Gemfile")
- end
-
- def create_pluginspec
- git_name = %x[git config user.name].chomp
- git_email = %x[git config user.email].chomp
-
- developer_id = git_email.split('@', 2).first || ''
-
- # Fallback values.
- git_name = 'TODO: Put your realname here' if git_name.empty?
- git_email = 'email@example.com' if git_email.empty?
-
- opts = {
- :developer_id => developer_id.empty? ? 'TODO: Put your jenkins-ci.org username here.' : developer_id,
- :developer_name => "#{git_name} <#{git_email}>"
- }
-
- template('templates/pluginspec.tt', "#{name}/#{name}.pluginspec", opts)
- end
-
- end
- end
- end
-end
View
4 lib/jenkins/plugin/cli/templates/Gemfile.tt
@@ -1,4 +0,0 @@
-
-source :rubygems
-
-gem "jenkins-plugin-runtime", "~> 0.1.13"
View
25 lib/jenkins/plugin/cli/templates/build_step.tt
@@ -1,25 +0,0 @@
-
-class <%= name.capitalize %><%= @step_class %> < Jenkins::Tasks::<%= @step_class %>
-
- display_name "<%= name.capitalize %> <%= @step_class.downcase %>"
-
- ##
- # Runs before the build begins
- #
- # @param [Jenkins::Model::Build] build the build which will begin
- # @param [Jenkins::Model::Listener] listener the listener for this build.
- def prebuild(build, listener)
- # do any setup that needs to be done before this build runs.
- end
-
- ##
- # Runs the step over the given build and reports the progress to the listener.
- #
- # @param [Jenkins::Model::Build] build on which to run this step
- # @param [Jenkins::Launcher] launcher the launcher that can run code on the node running this build
- # @param [Jenkins::Model::Listener] listener the listener for this build.
- def perform(build, launcher, listener)
- # actually perform the build step
- end
-
-end
View
28 lib/jenkins/plugin/cli/templates/pluginspec.tt
@@ -1,28 +0,0 @@
-
-Jenkins::Plugin::Specification.new do |plugin|
- plugin.name = <%= name.inspect %>
- plugin.display_name = <%= (name.capitalize + " Plugin").inspect %>
- plugin.version = '0.0.1'
- plugin.description = 'enter description here'
-
- # You should create a wiki-page for your plugin when you publish it, see
- # https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins#HostingPlugins-AddingaWikipage
- # This line makes sure it's listed in your POM.
- plugin.url = 'https://wiki.jenkins-ci.org/display/JENKINS/My+Plugin'
-
- # The first argument is your user name for jenkins-ci.org.
- plugin.developed_by <%= config[:developer_id].inspect %>, <%= config[:developer_name].inspect %>
-
- # This specifies where your code is hosted.
- # Alternatives include:
- # :github => 'myuser/my-plugin' (without myuser it defaults to jenkinsci)
- # :git => 'git://repo.or.cz/my-plugin.git'
- # :svn => 'https://svn.jenkins-ci.org/trunk/hudson/plugins/my-plugin'
- plugin.uses_repository :github => 'my-plugin'
-
- # This is a required dependency for every ruby plugin.
- plugin.depends_on 'ruby-runtime', '0.4'
-
- # This is a sample dependency for a Jenkins plugin, 'git'.
- plugin.depends_on 'git', '1.1.11'
-end
View
30 lib/jenkins/plugin/tools/bundle.rb
@@ -1,30 +0,0 @@
-
-module Jenkins
- class Plugin
- module Tools
- class Bundle
-
- def initialize(target)
- @target = target
- end
-
- def install
- require 'java'
- require 'bundler'
- puts "bundling..."
-
- # We set these in ENV instead of passing the --without and --path
- # options because the CLI options are remembered in .bundle/config and
- # will interfere with regular usage of bundle exec / install.
- Bundler.with_clean_env {
- ENV['BUNDLE_APP_CONFIG'] = "#{@target}/vendor/bundle"
- ENV['BUNDLE_WITHOUT'] = "development"
- ENV['BUNDLE_PATH'] = "#{@target}/vendor/gems"
- ENV.delete 'RUBYOPT'
- system('bundle --standalone')
- }
- end
- end
- end
- end
-end
View
107 lib/jenkins/plugin/tools/hpi.rb
@@ -1,107 +0,0 @@
-require 'zip/zip'
-require 'net/http'
-require 'uri'
-require 'fileutils'
-
-module Jenkins
- class Plugin
- module Tools
- # class for parsing hpi file and its manifests
- class Hpi
- attr_reader :file, :manifest
-
- # take the path name to the plugin file
- def initialize(file)
- @file = file
-
- # load and parse manifests
- Zip::ZipFile.open(@file) do |zip|
- zip.get_input_stream("META-INF/MANIFEST.MF") do |m|
- # main section of the manifest
- @manifest = parse_manifest(m.read)[0]
- end
- end
-
- # parse dependencies into hash
- @dependencies = {}
- deps = @manifest["Plugin-Dependencies"]
- if deps
- deps.split(",").each do |token|
- token = token.gsub(/;.+/,"") # trim off the optional portions
- name,ver = token.split(":")
- @dependencies[name] = ver
- end
- end
- end
-
- # given the plugin short name and the version number,
- # return the path name of the .hpi file by either locating the plugin locally or downloading it.
- def self.resolve(short_name,version)
- # this is where we expect the retrieved file to be
- cache = File.expand_path "~/.jenkins/cache/plugins/#{short_name}/#{version}/#{short_name}.hpi"
-
- return cache if File.exists?(cache)
-
- # now we start looking for places to find them
-
- # is it in the local maven2 repository?
- maven = File.expand_path "~/.m2/repository/org/jenkins-ci/plugins/#{short_name}/#{version}/#{short_name}-#{version}.hpi"
- return maven if File.exists?(maven)
-
- # download from the community update center
- FileUtils.mkdir_p(File.dirname(cache))
- open(cache+".tmp","wb") do |f|
- puts "Downloading #{short_name} #{version}"
- url = "http://updates.jenkins-ci.org/download/plugins/#{short_name}/#{version}/#{short_name}.hpi?for=ruby-plugin"
- puts " from #{url}"
- f.write fetch(url).body
- end
- FileUtils.mv cache+".tmp", cache
-
- return cache
- end
-
- # download with redirect support
- def self.fetch(uri, limit = 10)
- # You should choose better exception.
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
-
- response = Net::HTTP.get_response(URI.parse(uri))
- case response
- when Net::HTTPSuccess then response
- when Net::HTTPRedirection then fetch(response['location'], limit - 1)
- else
- response.error!
- end
- end
-
- # parse manifest file text into a hash
- def parse_manifest(txt)
- # separators
- nl = /\r\n|\n|\r[^\n]/
- secsep = /(#{nl}){2}/
-
- txt.split(secsep).reject { |s| s.chomp.length==0 }.map do |section|
- lines = []
- section.split(nl).each do |line|
- if line[0]==0x20
- lines.last << line[1..-1] # continuation of the previous line
- else
- lines << line
- end
- end
-
- # convert to hash
- hash = {}
- lines.each do |l|
- (k,v) = l.split(/: /,2)
- hash[k] = v
- end
-
- hash
- end
- end
- end
- end
- end
-end
View
29 lib/jenkins/plugin/tools/loadpath.rb
@@ -1,29 +0,0 @@
-module Jenkins
- class Plugin
- module Tools
- class Loadpath
- def initialize(*groups)
- require 'bundler'
- @groups = groups.empty? ? [:default] : groups
- end
-
- def to_path
- to_a.join(File::PATH_SEPARATOR)
- end
-
- def to_a
- [].tap do |paths|
- specs = Bundler.definition.specs_for @groups.map {|g| g.to_sym}
- for spec in specs
- next if spec.name == "bundler"
- for path in spec.require_paths
- paths << File.join(spec.full_gem_path, path)
- end
- end
- end
- end
-
- end
- end
- end
-end
View
80 lib/jenkins/plugin/tools/manifest.rb
@@ -1,80 +0,0 @@
-
-#require 'jenkins/plugin/version'
-
-require 'jenkins/plugin/version'
-require 'etc'
-
-module Jenkins
- class Plugin
- module Tools
- class Manifest
-
- def initialize(spec)
- @spec = spec
- end
-
- def write_hpi(io)
- w = Writer.new(io)
- w.put "Manifest-Version", "1.0"
- w.put "Created-By", Jenkins::Plugin::VERSION
- w.put "Build-Ruby-Platform", RUBY_PLATFORM
- w.put "Build-Ruby-Version", RUBY_VERSION
- w.put "Built-By", Etc.getlogin()
-
- w.put "Group-Id", "org.jenkins-ci.plugins"
- w.put "Short-Name", @spec.name
- w.put "Long-Name", @spec.display_name
- w.put "Url", @spec.url if @spec.url
-
- w.put "Plugin-Class", "ruby.RubyPlugin"
- w.put "Plugin-Version", @spec.version
- w.put "Jenkins-Version", "1.432"
-
- w.put "Plugin-Dependencies", @spec.dependencies.map{|k,v| "#{k}:#{v}"}.join(",")
- end
-
- def write_hpl(io, loadpath)
- write_hpi(io)
-
- w = Writer.new(io)
- w.put "Load-Path", loadpath.to_a.join(':')
- w.put "Lib-Path", "#{Dir.pwd}/lib/"
- w.put "Models-Path", "#{Dir.pwd}/models"
- # Stapler expects view erb/haml scripts to be in the JVM ClassPath
- w.put "Class-Path", "#{Dir.pwd}/views" if File.exists?("#{Dir.pwd}/views")
- # Directory for static images, javascript, css, etc. of this plugin.
- # The static resources are mapped under #CONTEXTPATH/plugin/SHORTNAME/
- w.put "Resource-Path", "#{Dir.pwd}/static"
- end
-
- class Writer
-
- MAX_LENGTH = 72.to_i
-
- def initialize(io)
- @io = io
- end
-
- def put(key, value)
- @io.puts "#{key}: #{manifest_truncate(value)}"
- end
-
- def manifest_truncate(message)
- if message.length < MAX_LENGTH
- return message
- end
-
- line = message[0 ... MAX_LENGTH] + "\n"
- offset = MAX_LENGTH
-
- while offset < message.length
- line += " #{message[offset ... (offset + MAX_LENGTH - 1)]}\n"
- offset += (MAX_LENGTH - 1)
- end
- return line
- end
- end
- end
- end
- end
-end
View
60 lib/jenkins/plugin/tools/package.rb
@@ -1,60 +0,0 @@
-require 'jenkins/plugin/tools/bundle'
-require 'jenkins/plugin/tools/manifest'
-require 'zip/zip'
-
-module Jenkins
- class Plugin
- module Tools
- class Package
-
- def initialize(spec,target)
- @target = target
- @spec = spec
- end
-
- # where to generate the package?
- def file_name
- file_name = "#{@target}/#{@spec.name}.hpi"
- end
-
- def build
- FileUtils.mkdir_p @target
-
- Bundle.new(@target).install
-
- manifest = Manifest.new(@spec)
-
- File.delete file_name if File.exists?(file_name)
-
- Zip::ZipFile.open(file_name, Zip::ZipFile::CREATE) do |zipfile|
- zipfile.get_output_stream("META-INF/MANIFEST.MF") do |f|
- manifest.write_hpi(f)
- f.puts "Bundle-Path: vendor/gems"
- end
- zipfile.mkdir("WEB-INF/classes")
-
- ["lib","models","#{@target}/vendor"].each do |d|
- Dir.glob("#{d}/**/*") do |f|
- if !File.directory? f
- p = f.gsub("#{@target}/",'')
- if p !~ %r{/cache/}
- zipfile.add("WEB-INF/classes/#{p}",f)
- end
- end
- end
- end
-
- # stapler expects views to be directly in the classpath without any prefix
- Dir.glob("views/**/*") do |f|
- if !File.directory? f
- zipfile.add("WEB-INF/classes/#{f[6..-1]}",f)
- end
- end
- end
- puts "#{@spec.name} plugin #{@spec.version} built to #{file_name}"
-
- end
- end
- end
- end
-end
View
70 lib/jenkins/plugin/tools/release.rb
@@ -1,70 +0,0 @@
-require 'jenkins/plugin/tools/bundle'
-require 'jenkins/plugin/tools/manifest'
-require 'jenkins/jenkins-ci.org/credential'
-require 'net/http'
-require 'erb'
-
-module Jenkins
- class Plugin
- module Tools
- # task for deploying a plugin
- class Release
-
- def initialize(spec,hpi,snapshot)
- @spec = spec
- @hpi = hpi # hpi file to release
- @snapshot = snapshot # if true, deploy as a snapshot, otherwise as release
- end
-
- def check_error(rsp)
- # in case of 401 Unauthorized, the server just resets the connection and Net::HTTP fails to parse the response,
- # so we don't really get any meaningful error message.
- rsp.value # TODO: is this how we check for the error?
- end
-
- def each_developer
- @spec.developers.each do |id, name|
- email = ''
- if name =~ /^(.*)<([^>]+)>$/
- name = $1
- email = $2.strip
- end
-
- yield id, name.strip, email
- end
- end
-
- def run
- cred = Jenkins::CiOrg::Credential.new
- if !cred.has_credential? then
- raise Exception.new("no credential available to connect to jenkins-ci.org. Please create ~/.jenkins-ci.org. See https://wiki.jenkins-ci.org/display/JENKINS/Dot+Jenkins+Ci+Dot+Org")
- end
-
- http = Net::HTTP.new("maven.jenkins-ci.org",8081)
-
- puts @snapshot ? "deploying as a snapshot" : "deploying as a release"
- puts "Generating POM"
- version = @snapshot ? @spec.version+"-SNAPSHOT" : @spec.version
- pom = ERB.new(File.read(File.dirname(__FILE__)+"/templates/release-pom.xml.erb")).result(binding)
-
- path = "/content/repositories/#{@snapshot?'snapshots':'releases'}/org/jenkins-ci/ruby-plugins/#{@spec.name}/#{version}/#{@spec.name}-#{version}"
- req = Net::HTTP::Put.new("#{path}.pom")
- req.body = pom
- req.basic_auth(cred.user_name,cred.password)
- check_error(http.request(req))
-
- puts "Uploading #{@hpi}"
- File.open(@hpi,'r') do |f|
- req = Net::HTTP::Put.new("#{path}.hpi")
- req.body_stream = f
- req.basic_auth(cred.user_name,cred.password)
- req.content_length = File.size(@hpi)
- check_error(http.request(req))
- end
-
- puts "See http://maven.jenkins-ci.org"+File.dirname(path)
- end
- end
- end
- end
-end
View
61 lib/jenkins/plugin/tools/resolver.rb
@@ -1,61 +0,0 @@
-require 'net/http'
-
-module Jenkins
- class Plugin
- module Tools
- class Resolver
-
- def initialize(spec, dir)
- @spec = spec
- @dir = dir
- FileUtils.mkdir_p(dir) unless File.directory? @dir
- end
-
- def resolve!
- @spec.dependencies.each do |name, version|
- FileUtils.cp resolve(name, version), @dir
- end
- end
-
- def resolve(short_name,version)
- # this is where we expect the retrieved file to be
- cache = File.expand_path "~/.jenkins/cache/plugins/#{short_name}/#{version}/#{short_name}.hpi"
-
- return cache if File.exists?(cache)
-
- # now we start looking for places to find them
-
- # is it in the local maven2 repository?
- maven = File.expand_path "~/.m2/repository/org/jenkins-ci/plugins/#{short_name}/#{version}/#{short_name}-#{version}.hpi"
- return maven if File.exists?(maven)
-
- # download from the community update center
- FileUtils.mkdir_p(File.dirname(cache))
- open(cache+".tmp","wb") do |f|
- puts "Downloading #{short_name} #{version}"
- url = "http://updates.jenkins-ci.org/download/plugins/#{short_name}/#{version}/#{short_name}.hpi?for=ruby-plugin"
- puts " from #{url}"
- f.write fetch(url).body
- end
- FileUtils.mv cache+".tmp", cache
-
- return cache
- end
-
- # download with redirect support
- def fetch(uri, limit = 10)
- # You should choose better exception.
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
-
- response = Net::HTTP.get_response(URI.parse(uri))
- case response
- when Net::HTTPSuccess then response
- when Net::HTTPRedirection then fetch(response['location'], limit - 1)
- else
- response.error!
- end
- end
- end
- end
- end
-end
View
49 lib/jenkins/plugin/tools/server.rb
@@ -1,49 +0,0 @@
-require 'jenkins/plugin/tools/loadpath'
-require 'jenkins/plugin/tools/resolver'
-require 'jenkins/plugin/tools/manifest'
-require 'jenkins/war'
-require 'fileutils'
-
-module Jenkins
- class Plugin
- module Tools
- class Server
-
- def initialize(spec, workdir, war)
- @spec = spec
- @workdir = workdir
- @plugindir = "#{workdir}/plugins"
- @war = war || Jenkins::War::LOCATION
- end
-
- def run!
- FileUtils.mkdir_p(@plugindir)
- loadpath = Jenkins::Plugin::Tools::Loadpath.new
- manifest = Jenkins::Plugin::Tools::Manifest.new(@spec)
- resolver = Jenkins::Plugin::Tools::Resolver.new(@spec, @plugindir)
-
- resolver.resolve!
- # generate the plugin manifest
-
- File.open("#{@plugindir}/#{@spec.name}.hpl",mode="w+") do |f|
- manifest.write_hpl(f, loadpath)
- end
-
-
- # execute Jenkins
- args = []
- args << "java"
- args << "-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"
- args << "-DJENKINS_HOME=#{@workdir}"
- args << "-Dstapler.trace=true"
- args << "-Ddebug.YUI=true"
-# args << "-Djruby.debug.loadService=true"
-# args << "-Djruby.debug.loadService.timing=true"
- args << "-jar"
- args << @war
- exec *args
- end
- end
- end
- end
-end
View
54 lib/jenkins/plugin/tools/templates/release-pom.xml.erb
@@ -1,54 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jenkins-ci.plugins</groupId>
- <artifactId>plugin</artifactId>
- <version>1.420</version>
- </parent>
-
- <groupId>org.jenkins-ci.ruby-plugins</groupId>
- <artifactId><%= @spec.name %></artifactId>
- <version><%= version %></version>
- <name><%= @spec.display_name %></name>
- <description><%= @spec.description %></description>
- <packaging>hpi</packaging>
-
-<% if @spec.url %>
- <url><%= @spec.url %></url>
-<% end %>
-
- <repositories>
- <repository>
- <id>m.g.o-public</id>
- <url>http://maven.glassfish.org/content/groups/public/</url>
- </repository>
- </repositories>
-
- <developers>
-<% each_developer do |id, name, email| %>
- <developer>
- <id><%= id %></id>
- <name><%= name %></name>
-<% if not email.empty? %>
- <email><%= email %></email>
-<% end %>
- </developer>
-<% end %>
- </developers>
-
- <dependencies>
-<% @spec.dependencies.each do |k,v| %>
- <dependency>
- <groupId>org.jenkins-ci.plugins</groupId><!-- TODO: needs to figure out correct groupId -->
- <artifactId><%= k %></artifactId>
- <version><%= v %></version>
- </dependency>
-<% end %>
- </dependencies>
-
-<% if @spec.repository %>
- <scm>
- <connection>scm:<%= @spec.repository[:type] %>:<%= @spec.repository[:url] %></connection>
- </scm>
-<% end %>
-</project>
View
5 lib/jenkins/plugin/version.rb
@@ -1,5 +0,0 @@
-module Jenkins
- class Plugin
- VERSION = "0.1.16"
- end
-end
View
52 lib/jenkins/rake.rb
@@ -1,52 +0,0 @@
-require 'jenkins/plugin/version'
-require 'jenkins/plugin/specification'
-require 'jenkins/plugin/tools/hpi'
-require 'jenkins/plugin/tools/loadpath'
-require 'zip/zip'
-
-module Jenkins
- # given the IO handle, produce the basic manifest entries that are common between hpi and hpl formats
-
- def self.spec
- @spec ||= Jenkins::Plugin::Specification.load(Dir['*.pluginspec'].first)
- end
-
- class Rake
- def self.install_tasks
- self.new.install
- end
-
- include ::Rake::DSL if defined? ::Rake::DSL
-
- def install
- desc "Directory used as JENKINS_HOME during 'rake server'"
- directory work = "work"
-
- desc "remove built artifacts"
- task :clean do
- sh "rm -rf pkg"
- sh "rm -rf vendor"
- end
-
- desc "output the development servers loadpath"
- task :loadpath do
- loadpath = Jenkins::Plugin::Tools::Loadpath.new(:default)
- puts loadpath.to_path
- end
-
- desc "package up stuff into HPI file"
- task :package do
- require 'jenkins/plugin/tools/package'
- Jenkins::Plugin::Tools::Package.new(Jenkins.spec,"pkg").build
- end
-
- desc "run a Jenkins server with this plugin"
- task :server do
- require 'jenkins/plugin/tools/server'
-
- server = Jenkins::Plugin::Tools::Server.new(Jenkins.spec, "work")
- server.run!
- end
- end
- end
-end

Showing you all comments on commits in this comparison.

@buildhive

Jenkins » jpi.rb #2 FAILURE
Looks like this commit caused a build failure
(what's this?)

Something went wrong with that request. Please try again.