- 2014.10.14, 16:18
- here's a recipe how to publish Fingerprints from Jenkins BuildFlow plugin (Groovy):
I donate this code to PUBLIC DOMAIN:
def fingerprint_name = "hudsonBuild.properties"
def buildStartNumber = upstream.number
out.println "* this build triggered by: $buildStartNumber"
/** copy file from given (upstream) build workspace, returning the copied File (needed for calling Fingerprinter) */
def copy_to_current_workspace( file_name, from_workspace )
{
def upstream_fingerprint = new File( from_workspace + "/" + file_name )
out.println "Copying fingerprint file from upstream $upstream_fingerprint"
def current_workspace = build.environment["WORKSPACE"]
def current_workspace_fingerprint = new File( current_workspace + "/" + file_name )
out.println " . copy to $current_workspace_fingerprint"
def ant_builder = new AntBuilder()
ant_builder.copy( file: upstream_fingerprint, tofile: current_workspace_fingerprint )
return current_workspace_fingerprint
}
/** register the fingerprint File with Jenkins tracking, returning md5sum (needed to providing FingerprintAction Facet to build) */
def register_fingerprint_entry( workspace_file )
{
def md5sum = new hudson.FilePath( workspace_file ).digest()
def finger_map = jenkins.model.Jenkins.getInstance().getFingerprintMap()
def fingerprint_entry = finger_map.getOrCreate( null, workspace_file.name, md5sum ) // do not claim to originate the fingerprint
fingerprint_entry.addFor( build ) // actually registers the fingerprint with this build
return md5sum
}
/** ask jenkins to show 'See Fingerprints' link on build */
def register_action_facet( fingerprint_name, md5sum )
{
// record the fact that build has fingerprints section/facet by adding FingerprintAction display link to build
def record = [:]
record.put( fingerprint_name, md5sum )
out.println " . record: $record"
def fingerprinter = build.getAction( hudson.tasks.Fingerprinter.FingerprintAction.class )
if( fingerprinter != null ) {
fingerprinter.add( record )
out.println " . used existing fingerinter action"
} else {
build.addAction( new hudson.tasks.Fingerprinter.FingerprintAction( build, record ) )
out.println " . added fingerprinter action"
}
}
/** do it */
def register_fingerprint( workspace_file )
{
def md5sum = register_fingerprint_entry( workspace_file )
register_action_facet( workspace_file.name, md5sum )
}
def workspace_fingerprint = copy_to_current_workspace( fingerprint_name, upstream.environment["WORKSPACE"] )
register_fingerprint( workspace_fingerprint )
-
0 rakstair doma
- 2014.05.02, 17:59
- I was fighting a really nasty persistent issue that Tomcat would fail to start if launched from Ant script like so (part of complicated ant script that fills out placeholders conditionally and so on, executed by Jenkins):
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true" clonevm="true">
<jvmarg value="-XX:+UseParallelOldGC"/>
<jvmarg value="-verbose:gc"/>
<jvmarg value="-XX:+PrintGCTimeStamps"/>
<jvmarg value="-XX:+PrintGCDetails"/>
<jvmarg value="-Xloggc:${tomcat.base}/logs/gcLog_${jvmRoute}.log"/>
...
<jvmarg value="-Djava.util.logging.config.file=${tomcat.base}/conf/logging.properties"/>
<jvmarg value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"/>
<jvmarg value="-Dcom.sun.management.jmxremote=true"/>
<jvmarg value="-Dcom.sun.management.jmxremote.port=${port.jmx}"/>
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false"/>
<jvmarg value="-Dcom.sun.management.jmxremote.ssl=false"/>
<jvmarg value="${solrProperty}"/>
<jvmarg line="${JAVA_OPTS}"/>
<jvmarg line="${jacocoArgLine}"/>
<env key="APP_CONFIG_ROOT" path="${APP_CONFIG_ROOT}"/>
</java>
The symptom is that it fails with following error:
Could not load Logmanager "org.apache.juli.ClassLoaderLogManager"
java.lang.ClassNotFoundException: org.apache.juli.ClassLoaderLogManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[...]
at java.util.logging.LogManager.(LogManager.java:173)
at java.util.logging.Logger.demandLogger(Logger.java:336)
at java.util.logging.Logger.getLogger(Logger.java:390)
at com.sun.jmx.remote.util.ClassLogger.(ClassLogger.java:55)
at sun.management.jmxremote.ConnectorBootstrap.(ConnectorBootstrap.java:823)
at sun.management.Agent.startAgent(Agent.java:260)
at sun.management.Agent.startAgent(Agent.java:456)
Can't load log handler "1catalina.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[...]
at sun.management.Agent.startAgent(Agent.java:260)
at sun.management.Agent.startAgent(Agent.java:456)
Can't load log handler "1catalina.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[...]
at sun.management.Agent.startAgent(Agent.java:456)
Can't load log handler "2localhost.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 2localhost.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 2localhost.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[...]
at sun.management.Agent.startAgent(Agent.java:456)
Can't load log handler "3manager.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 3manager.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 3manager.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[...]
at sun.management.Agent.startAgent(Agent.java:456)
Can't load log handler "4host-manager.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 4host-manager.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 4host-manager.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[...]
at sun.management.Agent.startAgent(Agent.java:456)
Error: Could not find or load main class
It turns out, the error is really simple.
If placeholders for <jvmarg value="${solrProperty}"/>, <jvmarg line="${JAVA_OPTS}"/>, <jvmarg line="${jacocoArgLine}"/> are somehow empty, then Tomcat will crash and burn.
Furthermore, they can't be empty strings. And they can't be standalone strings. You can put some nonsense like "-Dpunk=nown" in place of those, and Tomcat starts happily up.
Make sure all placeholders are filled out.
upd: The empty arg of <jvmarg value="${solrProperty}"/>
is the real culprit. It should be jvmarg line=... .
-
0 rakstair doma