Skip to content

Instantly share code, notes, and snippets.

View kohsuke's full-sized avatar
🏠
WFH

Kohsuke Kawaguchi kohsuke

🏠
WFH
View GitHub Profile
require 'jenkins/plugin/behavior'
module Jenkins
#
# Defines the equivalent of `hudson.Extension`
#
module Extension
extend Plugin::Behavior
implemented do |cls|
import org.jruby.ext.posix.*;
import hudson.os.*;
class MyHandler implements POSIXHandler {
public void error(POSIX.ERRORS errors, String s) {
throw new PosixException(s,errors);
}
public void unimplementedError(String s) {
throw new UnsupportedOperationException(s);
root@cucumber:/var/log/apache2/mirrors.jenkins-ci.org# mb scan -d updates ftp-nyc.osuosl.org
Tue Apr 10 01:24:03 2012 ftp-nyc.osuosl.org: starting
Tue Apr 10 01:24:03 2012 ftp-nyc.osuosl.org: files in 'updates' before scan: 33
Tue Apr 10 01:24:04 2012 ftp-nyc.osuosl.org: scanned 33 files (25/s) in 1s
Tue Apr 10 01:24:04 2012 ftp-nyc.osuosl.org: files to be purged: 0
Tue Apr 10 01:24:04 2012 ftp-nyc.osuosl.org: total files in 'updates' after scan: 33 (delta: 0)
Tue Apr 10 01:24:04 2012 ftp-nyc.osuosl.org: purged old files in 0s.
Tue Apr 10 01:24:04 2012 ftp-nyc.osuosl.org: done.
Completed in 1 seconds
% git remote -v
origin ssh://git@git.cloudbees.com/cloudbees/jenkins-validated-merge-plugin.git (fetch)
origin ssh://git@git.cloudbees.com/cloudbees/jenkins-validated-merge-plugin.git (push)
[~/ws/cloudbees/jenkins-validated-merge-plugin@atlas] (master)
% git push origin
usage: gitosis-serve [OPTS] USER
gitosis-serve: error: Missing argument USER.
fatal: The remote end hung up unexpectedly
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
... call into Velocity ...
} finally {
Thread.currentThread().setContextClassLoader(old);
}
% nmap -P0 -p 22 repo-internal.cloudbees.com
Starting Nmap 5.21 ( http://nmap.org ) at 2012-05-25 17:51 PDT
Nmap scan report for repo-internal.cloudbees.com (184.73.168.54)
Host is up.
rDNS record for 184.73.168.54: ec2-184-73-168-54.compute-1.amazonaws.com
PORT STATE SERVICE
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 2.10 seconds
class Foo
def initialize
@x=10
end
end
f = Foo.new
i = 1
b = f.instance_eval do
# this binding can see all members of f (like @x) as well as variables in the outer sopce (like i)
@kohsuke
kohsuke / gist:2844371
Created May 31, 2012 15:56
Running cucumber embedded with pry-plugin
require 'cucumber/cli/main'
Cucumber::Cli::Main.new(['cucumber-test/features'],output,output).execute!
"pool-3-thread-1" Id=33 Group=main TIMED_WAITING
at java.lang.Thread.sleep(Native Method)
at com.cloudbees.hudson.service.BaseRequest.poll(BaseRequest.java:70)
at com.cloudbees.hudson.service.AcquireSlaveRequest.acquire(AcquireSlaveRequest.java:90)
at com.cloudbees.hudson.service.ProvidoreSwarm.acquire(ProvidoreSwarm.java:77)
at com.cloudbees.hudson.plugins.SwarmCloud$1.call(SwarmCloud.java:105)
at com.cloudbees.hudson.plugins.SwarmCloud$1.call(SwarmCloud.java:97)
public static String getActionUrl(String itUrl,Action action) {
String urlName = action.getUrlName();
if(urlName==null) return null; // to avoid NPE and fail to render the whole page
if(SCHEME.matcher(urlName).find())
return urlName; // absolute URL
if(urlName.startsWith("/"))
return joinPath(Stapler.getCurrentRequest().getContextPath(),urlName);
else
// relative URL name
return urlName;