Hi,
I'm working on a Jenkins plugin to gather metrics from completed jobs.
This primarily involves gathering label information from Executors. I'm
using RunListener that looks something like this:
@Extension
public class MyRunListener extends RunListener<Run> implements Describable<
MyRunListener> {
@Override
public void onCompleted(Run run, @Nonnull TaskListener listener) {
// collect executor labels, send them off to an API endpoint
}
}
This is working fine for most of my projects. Pipeline, Multibranch, and
Freestyle jobs each trigger onCompleted() when the build finishes. I've
noticed some odd behavior from Maven projects though; they trigger
onCompleted twice for each build, instead of just once.
Here are some things I've noticed:
- The first time my code is triggered, run.getParent().getClass() is of
type hudson.maven.MavenModule, and the executor is null (run.getExecutor()
== null), so I can't pull any information from the Executor. The url in
the build data also adds the artifact id into the url like so:
http://localhost/jenkins/job/maven-job/
*com.company.jenkins.plugins$artifactidname*/5/ which makes for a
non-working link.
- The second time it is triggered, run.getParent().getClass is of type
hudson.maven.MavenModuleSet, and run.getExecutor() returns an Executor with
node information. The url in the build data points to the correct build
location: http://localhost/jenkins/job/maven-job/5/. This appears to be
the information I want.
I'm wondering what the difference is between MavenModule and
MavenModuleSet. Can I safely ignore anything of type MavenModule for my
purposes, without losing any job data? In other words, are there any
scenarios where a Maven project would NOT behave like this, and only
trigger my Listener once, as a MavenModule or MavenModuleSet, but not both?
Thanks!
Kyle
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/0f1bf9d8-4ca0-40bc-943b-defdc9d1efd5%40googlegroups.com.