jenkins-plugin 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/jenkins-plugin.gemspec +2 -2
- data/lib/jenkins/jenkins-ci.org/credential.rb +39 -0
- data/lib/jenkins/plugin/cli.rb +11 -1
- data/lib/jenkins/plugin/cli/new.rb +16 -2
- data/lib/jenkins/plugin/cli/templates/Gemfile.tt +1 -1
- data/lib/jenkins/plugin/cli/templates/pluginspec.tt +22 -3
- data/lib/jenkins/plugin/tools/manifest.rb +5 -3
- data/lib/jenkins/plugin/tools/package.rb +9 -5
- data/lib/jenkins/plugin/tools/release.rb +70 -0
- data/lib/jenkins/plugin/tools/templates/release-pom.xml.erb +54 -0
- data/lib/jenkins/plugin/version.rb +1 -1
- data/lib/jenkins/rake.rb +1 -1
- metadata +13 -9
data/jenkins-plugin.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["cowboyd@thefrontside.net"]
|
11
11
|
s.homepage = "http://github.com/cowboyd/jenkins-plugin"
|
12
12
|
s.summary = %q{Tools for creating and building Jenkins Ruby plugins}
|
13
|
-
s.description = %q{
|
13
|
+
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.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "jenkins-plugin"
|
16
16
|
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "thor"
|
24
24
|
s.add_dependency "jenkins-war", ">= 1.427"
|
25
25
|
s.add_dependency "bundler", "~> 1.1.rc"
|
26
|
-
s.add_dependency "jenkins-plugin-runtime", "~> 0.1.
|
26
|
+
s.add_dependency "jenkins-plugin-runtime", "~> 0.1.13"
|
27
27
|
|
28
28
|
s.add_development_dependency "rspec", "~> 2.0"
|
29
29
|
s.add_development_dependency "cucumber", "~> 1.0"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Jenkins
|
2
|
+
class CiOrg
|
3
|
+
# credential to access jenkins-ci.org
|
4
|
+
# TODO: move it elsewhere
|
5
|
+
class Credential
|
6
|
+
CREDENTIAL = File.expand_path("~/.jenkins-ci.org")
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@props = {}
|
10
|
+
|
11
|
+
if File.exists?(CREDENTIAL) then
|
12
|
+
File.open(CREDENTIAL,'r') do |f|
|
13
|
+
f.each_line do |l|
|
14
|
+
if l[0]=='#' then
|
15
|
+
return # comment
|
16
|
+
end
|
17
|
+
|
18
|
+
k,v = l.split("=",2)
|
19
|
+
@props[k]=v.strip
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# do we already have the credential?
|
26
|
+
def has_credential?
|
27
|
+
@props["userName"] && @props["password"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def user_name
|
31
|
+
@props["userName"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def password
|
35
|
+
@props["password"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/jenkins/plugin/cli.rb
CHANGED
@@ -19,7 +19,9 @@ module Jenkins
|
|
19
19
|
desc "build", "build plugin into .hpi file suitable for distribution"
|
20
20
|
def build
|
21
21
|
require 'jenkins/plugin/tools/package'
|
22
|
-
Tools::Package.new("pkg")
|
22
|
+
pkg = Tools::Package.new(spec, "pkg")
|
23
|
+
pkg.build
|
24
|
+
pkg
|
23
25
|
end
|
24
26
|
|
25
27
|
desc "server", "run a test server with plugin"
|
@@ -33,6 +35,14 @@ module Jenkins
|
|
33
35
|
end
|
34
36
|
map "s" => "server"
|
35
37
|
|
38
|
+
desc "release", "release to jenkins-ci.org"
|
39
|
+
method_option :release, :desc => "deploy as a release (as opposed to a snapshot)", :type => :boolean
|
40
|
+
def release
|
41
|
+
require 'jenkins/plugin/tools/release'
|
42
|
+
|
43
|
+
Tools::Release.new(spec,build().file_name, !options[:release]).run
|
44
|
+
end
|
45
|
+
|
36
46
|
desc "version", "show jpi version information"
|
37
47
|
def version
|
38
48
|
require 'jenkins/plugin/version'
|
@@ -16,10 +16,24 @@ module Jenkins
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def create_pluginspec
|
19
|
-
|
19
|
+
git_name = %x[git config user.name].chomp
|
20
|
+
git_email = %x[git config user.email].chomp
|
21
|
+
|
22
|
+
developer_id = git_email.split('@', 2).first || ''
|
23
|
+
|
24
|
+
# Fallback values.
|
25
|
+
git_name = 'TODO: Put your realname here' if git_name.empty?
|
26
|
+
git_email = 'email@example.com' if git_email.empty?
|
27
|
+
|
28
|
+
opts = {
|
29
|
+
:developer_id => developer_id.empty? ? 'TODO: Put your jenkins-ci.org username here.' : developer_id,
|
30
|
+
:developer_name => "#{git_name} <#{git_email}>"
|
31
|
+
}
|
32
|
+
|
33
|
+
template('templates/pluginspec.tt', "#{name}/#{name}.pluginspec", opts)
|
20
34
|
end
|
21
35
|
|
22
36
|
end
|
23
37
|
end
|
24
38
|
end
|
25
|
-
end
|
39
|
+
end
|
@@ -1,9 +1,28 @@
|
|
1
1
|
|
2
2
|
Jenkins::Plugin::Specification.new do |plugin|
|
3
|
-
plugin.name =
|
3
|
+
plugin.name = <%= name.inspect %>
|
4
|
+
plugin.display_name = <%= (name.capitalize + " Plugin").inspect %>
|
4
5
|
plugin.version = '0.0.1'
|
5
6
|
plugin.description = 'enter description here'
|
6
7
|
|
7
|
-
plugin
|
8
|
+
# You should create a wiki-page for your plugin when you publish it, see
|
9
|
+
# https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins#HostingPlugins-AddingaWikipage
|
10
|
+
# This line makes sure it's listed in your POM.
|
11
|
+
plugin.url = 'https://wiki.jenkins-ci.org/display/JENKINS/My+Plugin'
|
12
|
+
|
13
|
+
# The first argument is your user name for jenkins-ci.org.
|
14
|
+
plugin.developed_by <%= config[:developer_id].inspect %>, <%= config[:developer_name].inspect %>
|
15
|
+
|
16
|
+
# This specifies where your code is hosted.
|
17
|
+
# Alternatives include:
|
18
|
+
# :github => 'myuser/my-plugin' (without myuser it defaults to jenkinsci)
|
19
|
+
# :git => 'git://repo.or.cz/my-plugin.git'
|
20
|
+
# :svn => 'https://svn.jenkins-ci.org/trunk/hudson/plugins/my-plugin'
|
21
|
+
plugin.uses_repository :github => 'my-plugin'
|
22
|
+
|
23
|
+
# This is a required dependency for every ruby plugin.
|
24
|
+
plugin.depends_on 'ruby-runtime', '0.4'
|
25
|
+
|
26
|
+
# This is a sample dependency for a Jenkins plugin, 'git'.
|
8
27
|
plugin.depends_on 'git', '1.1.11'
|
9
|
-
end
|
28
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#require 'jenkins/plugin/version'
|
3
3
|
|
4
4
|
require 'jenkins/plugin/version'
|
5
|
+
require 'etc'
|
5
6
|
|
6
7
|
module Jenkins
|
7
8
|
class Plugin
|
@@ -18,15 +19,16 @@ module Jenkins
|
|
18
19
|
w.put "Created-By", Jenkins::Plugin::VERSION
|
19
20
|
w.put "Build-Ruby-Platform", RUBY_PLATFORM
|
20
21
|
w.put "Build-Ruby-Version", RUBY_VERSION
|
22
|
+
w.put "Built-By", Etc.getlogin()
|
21
23
|
|
22
24
|
w.put "Group-Id", "org.jenkins-ci.plugins"
|
23
25
|
w.put "Short-Name", @spec.name
|
24
|
-
w.put "Long-Name", @spec.
|
25
|
-
w.put "Url",
|
26
|
+
w.put "Long-Name", @spec.display_name
|
27
|
+
w.put "Url", @spec.url
|
26
28
|
|
27
29
|
w.put "Plugin-Class", "ruby.RubyPlugin"
|
28
30
|
w.put "Plugin-Version", @spec.version
|
29
|
-
w.put "Jenkins-Version", "1.
|
31
|
+
w.put "Jenkins-Version", "1.432"
|
30
32
|
|
31
33
|
w.put "Plugin-Dependencies", @spec.dependencies.map{|k,v| "#{k}:#{v}"}.join(",")
|
32
34
|
end
|
@@ -7,19 +7,23 @@ module Jenkins
|
|
7
7
|
module Tools
|
8
8
|
class Package
|
9
9
|
|
10
|
-
def initialize(target)
|
10
|
+
def initialize(spec,target)
|
11
11
|
@target = target
|
12
|
+
@spec = spec
|
13
|
+
end
|
14
|
+
|
15
|
+
# where to generate the package?
|
16
|
+
def file_name
|
17
|
+
file_name = "#{@target}/#{@spec.name}.hpi"
|
12
18
|
end
|
13
19
|
|
14
20
|
def build
|
15
21
|
FileUtils.mkdir_p @target
|
16
|
-
spec = Jenkins::Plugin::Specification.find!
|
17
22
|
|
18
23
|
Bundle.new(@target).install
|
19
24
|
|
20
|
-
manifest = Manifest.new(spec)
|
25
|
+
manifest = Manifest.new(@spec)
|
21
26
|
|
22
|
-
file_name = "#{@target}/#{spec.name}.hpi"
|
23
27
|
File.delete file_name if File.exists?(file_name)
|
24
28
|
|
25
29
|
Zip::ZipFile.open(file_name, Zip::ZipFile::CREATE) do |zipfile|
|
@@ -47,7 +51,7 @@ module Jenkins
|
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
50
|
-
puts "#{spec.name} plugin #{spec.version} built to #{file_name}"
|
54
|
+
puts "#{@spec.name} plugin #{@spec.version} built to #{file_name}"
|
51
55
|
|
52
56
|
end
|
53
57
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'jenkins/plugin/tools/bundle'
|
2
|
+
require 'jenkins/plugin/tools/manifest'
|
3
|
+
require 'jenkins/jenkins-ci.org/credential'
|
4
|
+
require 'net/http'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
module Jenkins
|
8
|
+
class Plugin
|
9
|
+
module Tools
|
10
|
+
# task for deploying a plugin
|
11
|
+
class Release
|
12
|
+
|
13
|
+
def initialize(spec,hpi,snapshot)
|
14
|
+
@spec = spec
|
15
|
+
@hpi = hpi # hpi file to release
|
16
|
+
@snapshot = snapshot # if true, deploy as a snapshot, otherwise as release
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_error(rsp)
|
20
|
+
# in case of 401 Unauthorized, the server just resets the connection and Net::HTTP fails to parse the response,
|
21
|
+
# so we don't really get any meaningful error message.
|
22
|
+
rsp.value # TODO: is this how we check for the error?
|
23
|
+
end
|
24
|
+
|
25
|
+
def each_developer
|
26
|
+
@spec.developers.each do |id, name|
|
27
|
+
email = ''
|
28
|
+
if name =~ /^(.*)<([^>]+)>$/
|
29
|
+
name = $1
|
30
|
+
email = $2.strip
|
31
|
+
end
|
32
|
+
|
33
|
+
yield id, name.strip, email
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def run
|
38
|
+
cred = Jenkins::CiOrg::Credential.new
|
39
|
+
if !cred.has_credential? then
|
40
|
+
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")
|
41
|
+
end
|
42
|
+
|
43
|
+
http = Net::HTTP.new("maven.jenkins-ci.org",8081)
|
44
|
+
|
45
|
+
puts @snapshot ? "deploying as a snapshot" : "deploying as a release"
|
46
|
+
puts "Generating POM"
|
47
|
+
version = @snapshot ? @spec.version+"-SNAPSHOT" : @spec.version
|
48
|
+
pom = ERB.new(File.read(File.dirname(__FILE__)+"/templates/release-pom.xml.erb")).result(binding)
|
49
|
+
|
50
|
+
path = "/content/repositories/#{@snapshot?'snapshots':'releases'}/org/jenkins-ci/ruby-plugins/#{@spec.name}/#{version}/#{@spec.name}-#{version}"
|
51
|
+
req = Net::HTTP::Put.new("#{path}.pom")
|
52
|
+
req.body = pom
|
53
|
+
req.basic_auth(cred.user_name,cred.password)
|
54
|
+
check_error(http.request(req))
|
55
|
+
|
56
|
+
puts "Uploading #{@hpi}"
|
57
|
+
File.open(@hpi,'r') do |f|
|
58
|
+
req = Net::HTTP::Put.new("#{path}.hpi")
|
59
|
+
req.body_stream = f
|
60
|
+
req.basic_auth(cred.user_name,cred.password)
|
61
|
+
req.content_length = File.size(@hpi)
|
62
|
+
check_error(http.request(req))
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "See http://maven.jenkins-ci.org"+File.dirname(path)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<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">
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
3
|
+
<parent>
|
4
|
+
<groupId>org.jenkins-ci.plugins</groupId>
|
5
|
+
<artifactId>plugin</artifactId>
|
6
|
+
<version>1.420</version>
|
7
|
+
</parent>
|
8
|
+
|
9
|
+
<groupId>org.jenkins-ci.ruby-plugins</groupId>
|
10
|
+
<artifactId><%= @spec.name %></artifactId>
|
11
|
+
<version><%= version %></version>
|
12
|
+
<name><%= @spec.display_name %></name>
|
13
|
+
<description><%= @spec.description %></description>
|
14
|
+
<packaging>hpi</packaging>
|
15
|
+
|
16
|
+
<% if @spec.url %>
|
17
|
+
<url><%= @spec.url %></url>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<repositories>
|
21
|
+
<repository>
|
22
|
+
<id>m.g.o-public</id>
|
23
|
+
<url>http://maven.glassfish.org/content/groups/public/</url>
|
24
|
+
</repository>
|
25
|
+
</repositories>
|
26
|
+
|
27
|
+
<developers>
|
28
|
+
<% each_developer do |id, name, email| %>
|
29
|
+
<developer>
|
30
|
+
<id><%= id %></id>
|
31
|
+
<name><%= name %></name>
|
32
|
+
<% if not email.empty? %>
|
33
|
+
<email><%= email %></email>
|
34
|
+
<% end %>
|
35
|
+
</developer>
|
36
|
+
<% end %>
|
37
|
+
</developers>
|
38
|
+
|
39
|
+
<dependencies>
|
40
|
+
<% @spec.dependencies.each do |k,v| %>
|
41
|
+
<dependency>
|
42
|
+
<groupId>org.jenkins-ci.plugins</groupId><!-- TODO: needs to figure out correct groupId -->
|
43
|
+
<artifactId><%= k %></artifactId>
|
44
|
+
<version><%= v %></version>
|
45
|
+
</dependency>
|
46
|
+
<% end %>
|
47
|
+
</dependencies>
|
48
|
+
|
49
|
+
<% if @spec.repository %>
|
50
|
+
<scm>
|
51
|
+
<connection>scm:<%= @spec.repository[:type] %>:<%= @spec.repository[:url] %></connection>
|
52
|
+
</scm>
|
53
|
+
<% end %>
|
54
|
+
</project>
|
data/lib/jenkins/rake.rb
CHANGED
@@ -37,7 +37,7 @@ module Jenkins
|
|
37
37
|
desc "package up stuff into HPI file"
|
38
38
|
task :package do
|
39
39
|
require 'jenkins/plugin/tools/package'
|
40
|
-
Jenkins::Plugin::Tools::Package.new("pkg").build
|
40
|
+
Jenkins::Plugin::Tools::Package.new(Jenkins.spec,"pkg").build
|
41
41
|
end
|
42
42
|
|
43
43
|
desc "run a Jenkins server with this plugin"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jenkins-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Charles Lowell
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-11-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-11-14 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rubyzip
|
@@ -65,7 +64,7 @@ dependencies:
|
|
65
64
|
requirements:
|
66
65
|
- - ~>
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
67
|
+
version: 0.1.13
|
69
68
|
type: :runtime
|
70
69
|
version_requirements: *id005
|
71
70
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +89,7 @@ dependencies:
|
|
90
89
|
version: "1.0"
|
91
90
|
type: :development
|
92
91
|
version_requirements: *id007
|
93
|
-
description:
|
92
|
+
description: Allows you to generate a new Ruby plugin project, build it, test it in Jenkins and release it to the Jenkins Update Center.
|
94
93
|
email:
|
95
94
|
- cowboyd@thefrontside.net
|
96
95
|
executables:
|
@@ -110,6 +109,7 @@ files:
|
|
110
109
|
- features/support/directory_structure.rb
|
111
110
|
- features/support/work.rb
|
112
111
|
- jenkins-plugin.gemspec
|
112
|
+
- lib/jenkins/jenkins-ci.org/credential.rb
|
113
113
|
- lib/jenkins/plugin/cli.rb
|
114
114
|
- lib/jenkins/plugin/cli/formatting.rb
|
115
115
|
- lib/jenkins/plugin/cli/generate.rb
|
@@ -122,11 +122,12 @@ files:
|
|
122
122
|
- lib/jenkins/plugin/tools/loadpath.rb
|
123
123
|
- lib/jenkins/plugin/tools/manifest.rb
|
124
124
|
- lib/jenkins/plugin/tools/package.rb
|
125
|
+
- lib/jenkins/plugin/tools/release.rb
|
125
126
|
- lib/jenkins/plugin/tools/resolver.rb
|
126
127
|
- lib/jenkins/plugin/tools/server.rb
|
128
|
+
- lib/jenkins/plugin/tools/templates/release-pom.xml.erb
|
127
129
|
- lib/jenkins/plugin/version.rb
|
128
130
|
- lib/jenkins/rake.rb
|
129
|
-
has_rdoc: true
|
130
131
|
homepage: http://github.com/cowboyd/jenkins-plugin
|
131
132
|
licenses: []
|
132
133
|
|
@@ -150,9 +151,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
requirements: []
|
151
152
|
|
152
153
|
rubyforge_project: jenkins-plugin
|
153
|
-
rubygems_version: 1.
|
154
|
+
rubygems_version: 1.8.9
|
154
155
|
signing_key:
|
155
156
|
specification_version: 3
|
156
157
|
summary: Tools for creating and building Jenkins Ruby plugins
|
157
|
-
test_files:
|
158
|
-
|
158
|
+
test_files:
|
159
|
+
- features/create-new-plugin.feature
|
160
|
+
- features/support/create_new_plugin_steps.rb
|
161
|
+
- features/support/directory_structure.rb
|
162
|
+
- features/support/work.rb
|