Skip to content

Instantly share code, notes, and snippets.

View kohsuke's full-sized avatar
🏠
WFH

Kohsuke Kawaguchi kohsuke

🏠
WFH
View GitHub Profile
@kohsuke
kohsuke / gist:1ec15ab87a16d52125d4de5bad317e46
Created September 18, 2016 05:46
Possible suggested syntax for android emulator
android.emulator(platform:'android-23') {
android.enableFlightMode()
sh './gradlew ...'
}
android.emulator(platform:'android-6.0', resolution:'800x600', locale:'en_GB', async:true) {
sh './gradlew someLengthyTask'
android.waitForBoot()
android.installApk '**/*.apk'
sh './run-tests-on-emulator'
// src/main/java/acme/RetryStep.java
ppackage acme;
class RetryStep extends GroovyStep {
private int times;
@DataBoundConstructor
public RetryStep(int times) {
this.times = times;
}
curl --verbose https://maven.glassfish.org/
* Trying 54.236.196.233...
* Connected to maven.glassfish.org (54.236.196.233) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 704 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* server certificate verification OK
* server certificate status verification SKIPPED
* SSL: certificate subject name (maven.java.net) does not match target host name 'maven.glassfish.org'
@kohsuke
kohsuke / javadocReverseIndex.groovy
Created July 21, 2016 20:53
javadocReverseIndex.groovy
#!/usr/bin/env groovy
/*
Generate index from short/full class name to the javadoc page, in the form of .htaccess.
This serves http://hudson-ci.org/javadoc/byShortName/
Push it as scp .htaccess hudson-ci.org:~/www/jenkins-ci.org/javadoc/byShortName
*/
index = new TreeMap();
base = new File("./target/site/apidocs");
base.eachFileRecurse { File f ->
@kohsuke
kohsuke / Foo.java
Created June 15, 2016 08:47
Java Puzzler of the day
public class Foo {
public static class A {
public int i = 1;
}
public static class B extends A {
public int i = 2;
}
public static void main(String[] args) {
{
// this message shows up in UI
status 'Making stuff right now'
sh 'make'
...
}
-------------------------------------------------------------------------------
Test set: com.cloudbees.groovy.cps.CpsTransformerTest
-------------------------------------------------------------------------------
Tests run: 49, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 3.663 sec <<< FAILURE!
each(com.cloudbees.groovy.cps.CpsTransformerTest) Time elapsed: 0.027 sec <<< FAILURE!
Assertion failed:
assert resultInCps==sh.evaluate(script)
| | | | |
0 | | 55
public
testPerform(org.jvnet.hudson.test.SleepBuilderTest) Time elapsed: 25.455 sec <<< ERROR!
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "findAncestorClass" is not defined. (http://localhost:51213/jenkins/adjuncts/a1646fe4/lib/form/radioBlock/radioBlock.js#56)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3652)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3630)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3715)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1759)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2137)
at script.(http://localhost:51213/jenkins/adjuncts/a1646fe4/lib/form/radioBlock/radioBlock.js:56)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:879)
at net.sourceforge.htmlunit.corejs.javascrip
java.io.IOException: Error parsing created date '2015-07-09 04:05:32.457763736 +0000 UTC' for object '45684afd47d0e02280322a14945094afb2610de9c41b933168a79700bfdbc30e'.
at org.jenkinsci.plugins.docker.workflow.client.DockerClient.getCreatedDate(DockerClient.java:169)
at org.jenkinsci.plugins.docker.workflow.client.DockerClient.getContainerRecord(DockerClient.java:263)
at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:138)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:136)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:105)