In case anyone else suffers from this issue, here is the workaround I found:

Substitute:

    def mavenVer =
currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version;

for

    def mavenVer =
currentBuild.getParent().getModules().toArray()[0].getVersion();

I don't know why the former broke, but the latter certainly works now.

On 17 April 2012 17:08, Daniel Jones <[email protected]> wrote:

> Hi all,
>
> Since an upgrade to Jenkins 1.460, a call to getMavenArtifacts() from an
> instance of MavenBuild returns null. Prior to the upgrade, the following
> post-build Groovy System script worked fine:
>
> import hudson.model.*;
> import hudson.util.*;
>
> def thr = Thread.currentThread();
> def currentBuild = thr?.executable;
> def mavenVer =
> currentBuild.getMavenArtifacts().getModuleRecords()[0].mainArtifact.version;
> def newParamAction = new hudson.model.ParametersAction(new
> hudson.model.StringParameterValue("MAVEN_VERSION", mavenVer));
> currentBuild.addAction(newParamAction);
>
> Does anyone know why this would have broken with the upgrade? Should I be
> using different classes instead?
>
> --
> Regards,
> Daniel Jones | Software Engineer, Platform Team
>
>
> Mendeley Ltd | London, UK | www.mendeley.com <http://www.mendeley.com/>
> Registered in England and Wales | Company Number 6419015
>



-- 
Regards,
Daniel Jones | Software Engineer, Platform Team


Mendeley Ltd | London, UK | www.mendeley.com <http://www.mendeley.com/>
Registered in England and Wales | Company Number 6419015

Reply via email to