I'm getting a null object when trying to get the deployed artifacts on command:
currentBuild.rawBuild.getAction(org.jenkinsci.plugins.pipeline.maven. publishers.MavenReport.class) do you know what am i doing wrong? On Thursday, May 30, 2019 at 11:51:13 PM UTC+2, Cyrille Le Clerc wrote: > > For the record, this FAQ section: > https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin#PipelineMavenPlugin-HowtouseMavenbuilddataingeneratedemails > > On Saturday, April 27, 2019 at 1:59:53 AM UTC+2, Harsh Shah wrote: >> >> Hi, Cyrille >> >> So this is how I do it. >> >> >> pipeline side invoke the method >> >> env.DEPLOYEDARTIFACTS = getDeployedArtifacts() >> >> @NonCPS >> def getDeployedArtifacts() { >> def deployed = '' >> Collection<org.jenkinsci.plugins.pipeline.maven.MavenArtifact> >> generatedArtifacts = >> currentBuild.rawBuild.getAction(org.jenkinsci.plugins.pipeline.maven.publishers.MavenReport.class).getGeneratedArtifacts(); >> for (org.jenkinsci.plugins.pipeline.maven.MavenArtifact >> generatedArtifact:generatedArtifacts) { >> if (generatedArtifact.isDeployed()) { >> >> deployed= deployed.concat(generatedArtifact.getUrl()) >> deployed = deployed.concat("===") >> deployed = >> deployed.concat(generatedArtifact.getShortDescription()) >> deployed = deployed.concat(",") >> } >> >> } >> return deployed >> } >> >> >> >> In EXT-MAIL-STANDARD-TEMPLATE >> >> <br /> >> <!-- MAVEN ARTIFACTS --> >> <j:set var="mbuilds" >> value="${it.getAction('org.jenkinsci.plugins.workflow.cps.EnvActionImpl').getOverriddenEnvironment()}" >> >> /> >> <h5>Deployed Artifacts</h5> >> <j:set var="generatedArtifacts" >> value="${mbuilds.get('DEPLOYEDArtifacts')}" /> >> >> <table width="100%" style="font-family: Verdana, Helvetica, sans >> serif; font-size: 11px; color: black"> >> <j:forEach var="artifacts" >> items="${generatedArtifacts.split(',')}" > >> <j:set var="artifact" value="${artifacts.split('===')}" /> >> <tr bgcolor="white" > >> <td class="bg1" colspan="2" style="font-family: Verdana, >> Helvetica, sans serif; font-size: 120%; color: black"> >> <li> >> <a href="${artifact[0]}"> >> ${artifact[1]} >> </a> >> </li> >> </td> >> </tr> >> </j:forEach> >> </table> >> <br /> >> >> >> >> >> >> >> On Monday, April 22, 2019 at 3:22:34 AM UTC-7, Cyrille Le Clerc wrote: >>> >>> Thanks Harsh, >>> >>> Could you please share with us an example of using maven pipeline >>> details in email generated by the email ext plug-in that I would add to the >>> documentation? >>> >>> Le lun. 22 avr. 2019 à 08:49, Harsh Shah <[email protected]> a écrit : >>> >>>> Collection<org.jenkinsci.plugins.pipeline.maven.MavenArtifact> >>>> generatedArtifacts = >>>> currentBuild.rawBuild.getAction(org.jenkinsci.plugins.pipeline.maven.publishers.MavenReport.class).getGeneratedArtifacts(); >>>> for >>>> (org.jenkinsci.plugins.pipeline.maven.MavenArtifact >>>> generatedArtifact:generatedArtifacts) { >>>> if (generatedArtifact.isDeployed()) { >>>> println("<a href='" + >>>> generatedArtifact.getUrl() + "'>" + >>>> generatedArtifact.getShortDescription() >>>> + "</a>"); >>>> } else { >>>> >>>> println(generatedArtifact.getShortDescription()); >>>> } >>>> } >>>> >>>> On Sunday, April 21, 2019 at 11:48:03 PM UTC-7, Harsh Shah wrote: >>>>> >>>>> Hi, >>>>> Thanks, this works. >>>>> >>>>> -Harsh >>>>> >>>>> On Sunday, April 21, 2019 at 9:15:50 AM UTC-7, Cyrille Le Clerc wrote: >>>>>> >>>>>> Hello Harsh, >>>>>> >>>>>> >>>>>> This seems to be possible but I have not tried. It should look like: >>>>>> >>>>>> Collection<org.jenkinsci.plugins.pipeline.maven.MavenArtifact> >>>>>> generatedArtifacts = build.getAction(org.jenkinsci.plugins.pipeline. >>>>>> maven.publishers.MavenReport.class).getGeneratedArtifacts(); >>>>>> >>>>>> for (MavenArtifact generatedArtifact:generatedArtifacts) { >>>>>> if (generatedArtifact.isDeployed()) { >>>>>> System.out.println("<a href='" + generatedArtifact.getUrl() + >>>>>> "'>" + generatedArtifact.getShortDescription() + "</a>"); >>>>>> } else { >>>>>> System.out.println(generatedArtifact.getShortDescription()); >>>>>> } >>>>>> } >>>>>> >>>>>> >>>>>> See source code >>>>>> https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.6.9/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenArtifact.java >>>>>> >>>>>> Cyrille >>>>>> >>>>>> On Friday, April 19, 2019 at 7:06:01 PM UTC+2, Harsh Shah wrote: >>>>>>> >>>>>>> The template is a pretty standard template like this >>>>>>> https://wiki.jenkins.io/download/attachments/3604514/jenkins-matrix-email-html.template?version=1&modificationDate=1332562186000&api=v2 >>>>>>> I am trying to get maven artifacts urls >>>>>>> >>>>>>> <!-- MAVEN ARTIFACTS --> >>>>>>> <j:set var="mbuilds" value="${build.moduleBuilds}" /> >>>>>>> <j:if test="${mbuilds!=null}"> >>>>>>> <div class="content"> >>>>>>> <h1>Build Artifacts</h1> >>>>>>> <j:forEach var="m" items="${mbuilds}"> >>>>>>> <h2>${m.key.displayName}</h2> >>>>>>> <j:forEach var="mvnbld" items="${m.value}"> >>>>>>> <j:set var="artifacts" value="${mvnbld.artifacts}" /> >>>>>>> <j:if test="${artifacts!=null and >>>>>>> artifacts.size()>0}"> >>>>>>> <ul> >>>>>>> <j:forEach var="f" items="${artifacts}"> >>>>>>> <li> >>>>>>> <a >>>>>>> href="${rooturl}${mvnbld.url}artifact/${f}">${f}</a> >>>>>>> </li> >>>>>>> </j:forEach> >>>>>>> </ul> >>>>>>> </j:if> >>>>>>> </j:forEach> >>>>>>> </j:forEach> >>>>>>> <br /> >>>>>>> </div> >>>>>>> </j:if> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Friday, April 19, 2019 at 9:30:49 AM UTC-7, Cyrille Le Clerc >>>>>>> wrote: >>>>>>>> >>>>>>>> do you have examples of integrations of the email ext plugin with >>>>>>>> other plugins? >>>>>>>> Is the integration based on environment variables? >>>>>>>> >>>>>>>> Cyrille >>>>>>>> >>>>>>>> On Friday, April 19, 2019 at 2:15:11 AM UTC+2, Harsh Shah wrote: >>>>>>>>> >>>>>>>>> Hi, >>>>>>>>> We have been using pipeline maven plugin and maven artifact >>>>>>>>> publisher to display deployed artifacts by the build. >>>>>>>>> >>>>>>>>> We also use ext-email plugin with a template to provide >>>>>>>>> notifications. >>>>>>>>> >>>>>>>>> How can I get the published maven artifacts from maven artifact >>>>>>>>> publisher in my email description? >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> -Harsh >>>>>>>>> >>>>>>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Jenkins Users" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/jenkinsci-users/sPAYLh1W1cM/unsubscribe >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/jenkinsci-users/f4ea394b-824e-4ba7-8664-46b205bb523d%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/jenkinsci-users/f4ea394b-824e-4ba7-8664-46b205bb523d%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >> On Monday, April 22, 2019 at 3:22:34 AM UTC-7, Cyrille Le Clerc wrote: >>> >>> Thanks Harsh, >>> >>> Could you please share with us an example of using maven pipeline >>> details in email generated by the email ext plug-in that I would add to the >>> documentation? >>> >>> Le lun. 22 avr. 2019 à 08:49, Harsh Shah <[email protected]> a écrit : >>> >>>> Collection<org.jenkinsci.plugins.pipeline.maven.MavenArtifact> >>>> generatedArtifacts = >>>> currentBuild.rawBuild.getAction(org.jenkinsci.plugins.pipeline.maven.publishers.MavenReport.class).getGeneratedArtifacts(); >>>> for >>>> (org.jenkinsci.plugins.pipeline.maven.MavenArtifact >>>> generatedArtifact:generatedArtifacts) { >>>> if (generatedArtifact.isDeployed()) { >>>> println("<a href='" + >>>> generatedArtifact.getUrl() + "'>" + >>>> generatedArtifact.getShortDescription() >>>> + "</a>"); >>>> } else { >>>> >>>> println(generatedArtifact.getShortDescription()); >>>> } >>>> } >>>> >>>> On Sunday, April 21, 2019 at 11:48:03 PM UTC-7, Harsh Shah wrote: >>>>> >>>>> Hi, >>>>> Thanks, this works. >>>>> >>>>> -Harsh >>>>> >>>>> On Sunday, April 21, 2019 at 9:15:50 AM UTC-7, Cyrille Le Clerc wrote: >>>>>> >>>>>> Hello Harsh, >>>>>> >>>>>> >>>>>> This seems to be possible but I have not tried. It should look like: >>>>>> >>>>>> Collection<org.jenkinsci.plugins.pipeline.maven.MavenArtifact> >>>>>> generatedArtifacts = build.getAction(org.jenkinsci.plugins.pipeline. >>>>>> maven.publishers.MavenReport.class).getGeneratedArtifacts(); >>>>>> >>>>>> for (MavenArtifact generatedArtifact:generatedArtifacts) { >>>>>> if (generatedArtifact.isDeployed()) { >>>>>> System.out.println("<a href='" + generatedArtifact.getUrl() + >>>>>> "'>" + generatedArtifact.getShortDescription() + "</a>"); >>>>>> } else { >>>>>> System.out.println(generatedArtifact.getShortDescription()); >>>>>> } >>>>>> } >>>>>> >>>>>> >>>>>> See source code >>>>>> https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.6.9/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenArtifact.java >>>>>> >>>>>> Cyrille >>>>>> >>>>>> On Friday, April 19, 2019 at 7:06:01 PM UTC+2, Harsh Shah wrote: >>>>>>> >>>>>>> The template is a pretty standard template like this >>>>>>> https://wiki.jenkins.io/download/attachments/3604514/jenkins-matrix-email-html.template?version=1&modificationDate=1332562186000&api=v2 >>>>>>> I am trying to get maven artifacts urls >>>>>>> >>>>>>> <!-- MAVEN ARTIFACTS --> >>>>>>> <j:set var="mbuilds" value="${build.moduleBuilds}" /> >>>>>>> <j:if test="${mbuilds!=null}"> >>>>>>> <div class="content"> >>>>>>> <h1>Build Artifacts</h1> >>>>>>> <j:forEach var="m" items="${mbuilds}"> >>>>>>> <h2>${m.key.displayName}</h2> >>>>>>> <j:forEach var="mvnbld" items="${m.value}"> >>>>>>> <j:set var="artifacts" value="${mvnbld.artifacts}" /> >>>>>>> <j:if test="${artifacts!=null and >>>>>>> artifacts.size()>0}"> >>>>>>> <ul> >>>>>>> <j:forEach var="f" items="${artifacts}"> >>>>>>> <li> >>>>>>> <a >>>>>>> href="${rooturl}${mvnbld.url}artifact/${f}">${f}</a> >>>>>>> </li> >>>>>>> </j:forEach> >>>>>>> </ul> >>>>>>> </j:if> >>>>>>> </j:forEach> >>>>>>> </j:forEach> >>>>>>> <br /> >>>>>>> </div> >>>>>>> </j:if> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Friday, April 19, 2019 at 9:30:49 AM UTC-7, Cyrille Le Clerc >>>>>>> wrote: >>>>>>>> >>>>>>>> do you have examples of integrations of the email ext plugin with >>>>>>>> other plugins? >>>>>>>> Is the integration based on environment variables? >>>>>>>> >>>>>>>> Cyrille >>>>>>>> >>>>>>>> On Friday, April 19, 2019 at 2:15:11 AM UTC+2, Harsh Shah wrote: >>>>>>>>> >>>>>>>>> Hi, >>>>>>>>> We have been using pipeline maven plugin and maven artifact >>>>>>>>> publisher to display deployed artifacts by the build. >>>>>>>>> >>>>>>>>> We also use ext-email plugin with a template to provide >>>>>>>>> notifications. >>>>>>>>> >>>>>>>>> How can I get the published maven artifacts from maven artifact >>>>>>>>> publisher in my email description? >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> -Harsh >>>>>>>>> >>>>>>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Jenkins Users" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/jenkinsci-users/sPAYLh1W1cM/unsubscribe >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/jenkinsci-users/f4ea394b-824e-4ba7-8664-46b205bb523d%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/jenkinsci-users/f4ea394b-824e-4ba7-8664-46b205bb523d%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- You received this message because you are subscribed to the Google Groups "Jenkins Users" 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-users/d94a54be-0b5d-48a6-8a13-ba63bcd0f2bf%40googlegroups.com.
