Hi Alvaro,

Thanks for your reply. So in a multi-branch project, do you have any better
proposal than to use the following?

withMaven(mavenLocalRepo: "/tmp/${env.BRANCH_NAME}/.repository") {
        // Run the maven build        sh "mvn clean package"

}

Since we're "mvn install"-ing snapshots, we cannot reuse the same .m2
repo for different branches...


On Tue, Aug 16, 2016 at 10:25 PM, Álvaro Lobato <alvarolob...@gmail.com>
wrote:

> Hello Stefan,
>
> An easy way to do it is to use the new Pipeline Maven
> <https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin> plugin.
> It allows you to define a local maven repository, relative to to the
> workspace of the job or with an absolute path, you can also use shell
> variables expansion. In your case would be as easy as using a job similar
> to this one:
>
> withMaven(mavenLocalRepo: '.repository') {
>         // Run the maven build        sh "mvn clean package"
>
> }
>
>
> This will execute the specified mvn command with a local repo on the
> folder .repository inside the workspace.
>
> You can also use other parameters to customise you maven behaviour or even
> auto-install it.  If you want more information check the plugin wiki page
> <https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin> or
> this thread from the forum
> <https://groups.google.com/forum/#!topic/jenkinsci-users/9vS0DpU9oeM>.
>
> It is still in beta phase, but working well so far.
>
> Cheers
> Alvaro
>
> El lunes, 15 de agosto de 2016, 18:36:30 (UTC+2), ST escribió:
>>
>> Hi!
>>
>> I am migrating our build pipeline from a set of maven-type jobs to a
>> multi-branch project defined in a Jenkinsfile, and I am wondering how
>> people solve the .m2 problem ? I cannot see any way to configure every
>> job/branch to have its own private .m2 repo through a comfortable boolean
>> config option, did I miss something?
>>
>> Otherwise I guess the solution is to set the .m2 path via
>> -Dmaven.repo.local. But how to best define this path so it is different for
>> every job/branch? Put it under /tmp/<GIT_BRANCH_NAME>? Any other more
>> elegant options?
>>
>> Best regards,
>>  stefan.
>>
>>
>> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/5970854a-5e55-4475-bf75-5da0227202d9%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/5970854a-5e55-4475-bf75-5da0227202d9%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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CABwQARtxFg8f82BxxM_aToua8Q3hG_qUsZqjrQt871cVkQOEtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to