Permalink
Browse files

add `new` generator

  • Loading branch information...
1 parent ef8a148 commit 74024fbe4556f90124aebf12e2a537526b9728db @cowboyd committed Sep 19, 2011
View
@@ -26,8 +26,16 @@ The gem provides the `jpi` executeable
jpi server # run a test server with plugin
jpi version # show jpi version information
-Once you have a plugin project, you can run a Jenkins test server like so:
+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
@@ -43,9 +51,6 @@ Once you have a plugin project, you can run a Jenkins test server like so:
INFO: Listed all plugins
Sep 19, 2011 12:01:39 PM ruby.RubyRuntimePlugin start
INFO: Injecting JRuby into XStream
- Loading models/builder.rb
- Loading logging_wrapper.rb
- Loading root_action.rb
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
@@ -61,5 +66,11 @@ Once you have a plugin project, you can run a Jenkins test server like so:
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
+
@@ -2,17 +2,15 @@
require 'thor'
require 'jenkins/plugin/specification'
require 'jenkins/plugin/cli/formatting'
+require 'jenkins/plugin/cli/new'
module Jenkins
class Plugin
class CLI < Thor
extend Formatting
- desc "new NAME", "create a new plugin called NAME"
- def new(name)
- shell.say "TODO: new(#{name})"
- end
+ register New, "new", "new NAME", "create a new plugin called NAME"
desc "generate", "generate code for extensions points"
def generate
@@ -37,7 +37,7 @@ 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
+ - tools to create, build, develop and release Jenkins plugins
Usage: jpi command [arguments] [options]
@@ -0,0 +1,25 @@
+
+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
+ template('templates/pluginspec.tt', "#{name}/#{name}.pluginspec")
+ end
+
+ end
+ end
+ end
+end
@@ -0,0 +1,4 @@
+
+source :rubygems
+
+gem "jenkins-plugin-runtime", "~> 0.1.5"
@@ -0,0 +1,8 @@
+
+Jenkins::Plugin::Specification.new do |plugin|
+ plugin.name = '<%= name %>'
+ plugin.version = '0.0.1'
+ plugin.description = 'enter description here'
+
+ plugin.depends_on 'ruby-runtime', '0.3'
+end
@@ -35,7 +35,7 @@ def write_hpl(io, loadpath)
io.puts "Lib-Path: #{Dir.pwd}/lib/"
io.puts "Models-Path: #{Dir.pwd}/models"
# Stapler expects view erb/haml scripts to be in the JVM ClassPath
- io.puts "Class-Path: #{Dir.pwd}/views"
+ io.puts "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/
io.puts "Resource-Path: #{Dir.pwd}/static"
@@ -1,5 +1,5 @@
module Jenkins
class Plugin
- VERSION = "0.1.7"
+ VERSION = "0.1.8"
end
end

0 comments on commit 74024fb

Please sign in to comment.