Class: Jenkins::Plugin::Specification
- Inherits:
-
Object
- Object
- Jenkins::Plugin::Specification
- Defined in:
- lib/jenkins/plugin/specification.rb
Constant Summary collapse
- GITHUB_URL_FORMAT =
'git://github.com/%s/%s.git'
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
A hash of dependencies, like ‘foo’ => ‘1.2.3’, ‘bar’ => ‘0.0.1’ Our dependency handling is not smart (yet).
-
#description ⇒ Object
Free form text description of the plugin.
-
#developers ⇒ Object
A hash of developers, ‘id’ => ‘name <email>’ or ‘id’ => ‘name’.
-
#display_name ⇒ Object
Retrieves the display name of the plugin.
-
#name ⇒ Object
The name of this plugin.
-
#repository ⇒ Object
readonly
A hash of :type => [:svn, :git], :url => url to repo.
-
#url ⇒ Object
URL to the wiki page of the plugin.
-
#version ⇒ Object
Plugin version.
Class Method Summary collapse
-
.find(dir = Dir.pwd) ⇒ Jenkins::Plugin::Specification
Looks inside ‘dir` for a file ending in .pluginspec, and if found, loads it.
-
.find!(dir = Dir.pwd) ⇒ Jenkins::Plugin::Specification
Attempts to ‘#find` a plugin spec in `dir` and raises an exception if unsuccessful.
-
.load(path) ⇒ Jenkins::Plugin::Specification
Evaluates ‘path` as ruby code, expecting it to contain an instance of `Jenkins::Plugin::Specification`.
Instance Method Summary collapse
-
#depends_on(plugin_name, version) ⇒ Object
Adds ‘plugin_name` as a pre-requisite of this plugin.
-
#developed_by(id, name = nil) ⇒ Object
Adds ‘id` to the list of developers - this is your jenkins-ci.org account, with the displayed name of `name`.
-
#initialize {|_self| ... } ⇒ Specification
constructor
A new instance of Specification.
-
#uses_repository(repo) ⇒ Object
Sets your repository to be ‘repo`.
-
#validate! ⇒ Object
Make sure that your specification is not corrupt.
Constructor Details
#initialize {|_self| ... } ⇒ Specification
Returns a new instance of Specification.
36 37 38 39 40 |
# File 'lib/jenkins/plugin/specification.rb', line 36 def initialize @dependencies = {} @developers = {} yield(self) if block_given? end |
Instance Attribute Details
#dependencies ⇒ Object
A hash of dependencies, like ‘foo’ => ‘1.2.3’, ‘bar’ => ‘0.0.1’ Our dependency handling is not smart (yet).
31 32 33 |
# File 'lib/jenkins/plugin/specification.rb', line 31 def dependencies @dependencies end |
#description ⇒ Object
Free form text description of the plugin. No character limit, but please, keep it civil.
21 22 23 |
# File 'lib/jenkins/plugin/specification.rb', line 21 def description @description end |
#developers ⇒ Object
A hash of developers, ‘id’ => ‘name <email>’ or ‘id’ => ‘name’
27 28 29 |
# File 'lib/jenkins/plugin/specification.rb', line 27 def developers @developers end |
#display_name ⇒ Object
Retrieves the display name of the plugin.
43 44 45 46 47 48 49 |
# File 'lib/jenkins/plugin/specification.rb', line 43 def display_name if @display_name @display_name else self.name.capitalize end end |
#name ⇒ Object
The name of this plugin. Will be used as a globally unique identifier inside the Jenkins server
11 12 13 |
# File 'lib/jenkins/plugin/specification.rb', line 11 def name @name end |
#repository ⇒ Object (readonly)
A hash of :type => [:svn, :git], :url => url to repo
34 35 36 |
# File 'lib/jenkins/plugin/specification.rb', line 34 def repository @repository end |
#url ⇒ Object
URL to the wiki page of the plugin
24 25 26 |
# File 'lib/jenkins/plugin/specification.rb', line 24 def url @url end |
#version ⇒ Object
Plugin version. This is used during dependency resolution
18 19 20 |
# File 'lib/jenkins/plugin/specification.rb', line 18 def version @version end |
Class Method Details
.find(dir = Dir.pwd) ⇒ Jenkins::Plugin::Specification
Looks inside ‘dir` for a file ending in .pluginspec, and if found, loads it.
117 118 119 120 121 122 123 124 |
# File 'lib/jenkins/plugin/specification.rb', line 117 def self.find(dir = Dir.pwd) dir = Pathname(dir) if spec_path = Pathname(dir).entries.find {|e| e.to_s =~ /\.pluginspec$/} load(dir.join(spec_path).to_s) end rescue Errno::ENOENT => e fail SpecificationNotFound, "#{dir} does not appear to be a directory" end |
.find!(dir = Dir.pwd) ⇒ Jenkins::Plugin::Specification
Attempts to ‘#find` a plugin spec in `dir` and raises an exception if unsuccessful
130 131 132 |
# File 'lib/jenkins/plugin/specification.rb', line 130 def self.find!(dir = Dir.pwd) find(dir) or fail SpecificationNotFound, "no plugin specification found in #{dir}" end |
.load(path) ⇒ Jenkins::Plugin::Specification
Evaluates ‘path` as ruby code, expecting it to contain an instance of `Jenkins::Plugin::Specification`.
108 109 110 111 |
# File 'lib/jenkins/plugin/specification.rb', line 108 def self.load(path) _path = path.to_s eval(File.read(_path), binding, _path, 1) end |
Instance Method Details
#depends_on(plugin_name, version) ⇒ Object
Adds ‘plugin_name` as a pre-requisite of this plugin. This can be the name of any Jenkins plugin written in Ruby, Java, or any other language. Version right now must be an exact version number.
55 56 57 |
# File 'lib/jenkins/plugin/specification.rb', line 55 def depends_on(plugin_name, version) dependencies[plugin_name] = version end |
#developed_by(id, name = nil) ⇒ Object
Adds ‘id` to the list of developers - this is your jenkins-ci.org account, with the displayed name of `name`. `name` can be “Your Name” or “Your Name <[email protected]>” if you want to include your e-mail.
62 63 64 |
# File 'lib/jenkins/plugin/specification.rb', line 62 def developed_by(id, name=nil) developers[id] = name || id end |
#uses_repository(repo) ⇒ Object
Sets your repository to be ‘repo`. `repo` is a hash of :type => url
Where :type is one of [:github, :git, :svn]
Valid uses:
* uses_repository :github => 'me/my-plugin'
* uses_repository :github => 'my-plugin'
* * Same as :github => 'jenkinsci/my-plugin'.
* uses_repository :git => 'git://repo.or.cz/my-plugin.git'
* uses_repository :svn =>
'https://svn.jenkins-ci.org/trunk/hudson/plugins/my-plugin'
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/jenkins/plugin/specification.rb', line 77 def uses_repository(repo) if @repository or repo.length != 1 fail SpecificationError , "You can only specify one repository" end type, url = repo.first case type.to_sym when :github org = 'jenkinsci' if url.include?('/') org, url = url.split('/', 2) end url = GITHUB_URL_FORMAT % [org, url] @repository = {:type => :git, :url => url}.freeze when :git, :svn @repository = {:type => type.to_sym, :url => url}.freeze end end |
#validate! ⇒ Object
Make sure that your specification is not corrupt.
98 99 100 101 102 |
# File 'lib/jenkins/plugin/specification.rb', line 98 def validate! [:name, :version, :description].each do |field| fail SpecificationError, "field may not be nil" unless send(field) end end |