project version from maven to sonar using hudson

前端 未结 5 676
情话喂你
情话喂你 2021-01-16 20:37

i am using maven2 , hudson and sonar while doing sonar analysis - i would like some way to append the Hudson build# to the maven version of the project

The project

5条回答
  •  星月不相逢
    2021-01-16 21:05

    Thanks To Andre for pointing me to the other link I did try it but was running into some issues as noted in the comments Assuming what I have done is just a workaround and there is a better solution ? ( I am using Hudson ) So I defined a new Job in Hudson ( Build a Maven 2/3 project (Legacy) ) Here I defined a "Groovy PostBuild" Copied the code in the link that Andre pointed me to :

    import hudson.model.*;
    import hudson.util.*;
    
    def thr = Thread.currentThread();
    def currentBuild = thr?.executable;
    def mavenVer = currentBuild.getParent().getModules().toArray()[0].getVersion();
    def newParamAction = new hudson.model.ParametersAction(new           
    hudson.model.StringParameterValue("MAVEN_VERSION", mavenVer));
    currentBuild.addAction(newParamAction);
    

    I then "Trigger parameterized build on other projects " and mentioned the job in which I wanted the maven version as mentioend in the pom

    Defined a parameter - ${MAVEN_VERSION}

    I was then able to get the value of this parameter in the "other" job

    So first thanks to Andre - he provided me a solution I am curious to know if this is a good approach another question I have is ( which maybe I will start a new thread ) is - how does a Hudson "Free style" job differ from a "Maven 2/3 legacy project"

    The reason I ask is the same Groovy script failed in a "free style" while it worked in a "Maven legacy"

    Thanks, satish

提交回复
热议问题