MultiBranch Mercurial JenkinsFile

WARNING; this configuration doesn’t seem to delete old builds. Ever, see; https://issues.jenkins-ci.org/browse/JENKINS-34738. I’ve worked around it by putting the following blurb near the top of my JenkinsFile


// https://issues.jenkins-ci.org/browse/JENKINS-34738
// https://stackoverflow.com/questions/35370810/how-do-i-use-jenkins-pipeline-properties-step/35471196#35471196
properties (
    [
        [
            $class: 'BuildDiscarderProperty',
            strategy: [
                $class: 'LogRotator',
                artifactDaysToKeepStr: '14',
                artifactNumToKeepStr: '3',
                daysToKeepStr: '14',
                numToKeepStr: '3'
            ]
        ]
    ]
)

This is just a “victory dance” sort of post about setting up a multi-branch build, for a Mercurial project, from a JenkinsFile. When I first tried to do this sthing, I recieved a message reading; ERROR: No configured Mercurial installation which was annoying.

I hadn’t needed to setup Mercurial before, why did I need to now?

Turns out, the workaround/worksforme from here this bug solves the problem by defining the default Mercuiral setup as … the … default?

Step 0; Setup SSH Keys

I don’t know if this is essential, or, what “worksforme” but … I have the Jenkins user using an SSH key with access to my server.

No credentials are stored in Jenkins.

This may or may not be practical; sorry.

Step 1; Define your Mercurial installation

Open Jenkins, Manage Jenkins > Global Tool Configuration / Mercurial / Mercurial installations...

On my Docker container, these settings worked snazzy.

merc-setup

Step 2; Project Setup

Now, you need to add a “Branch Source” to your Multi-Branch Pipeline which uses this Mercuial Installation. The image below illustrates the settings that I used;

merc-setup

Q’apala?

That should do it. The next time your project indexes it should be able to scan your repository for branch heads.

comments powered by Disqus
Peter LaValle avatar
Peter LaValle
Any links probably include affiliate ids for that sweet sweet kickback - and some programs require that I tell you. The contents of this blog are likely unrelated - as they include games, paints, and build tools.