Search code examples
jenkinsjenkins-pipelinecloudbees

Access Cloudbees private mount from Jenkins pipeline


When using a 'normal' Jenkins build job you are offered the possibility to mount your private repository (which it is by default). However using a pipeline job this configuration option is missing and the repository is not mounted by default.

[My Pipeline] Running shell script
+ ls -laR /private
/private:
total 9
drwxrwxrwx  2 root root  2 Aug 13  2013 .
dr-xr-xr-x 23 root root 32 Jul 28 10:47 ..

I require access to this private repository and I would like to know how to achieve this from a Jenkins pipeline (running in Cloudbees)


Solution

  • I dropped the question also at Cloudbees and this was their response: "this feature is not support on Pipeline, and there is no plan to implement its support. You should consider using the Configuration File Provider plugin."

    https://wiki.jenkins.io/display/JENKINS/Config+File+Provider+Plugin#ConfigFileProviderPlugin-UsingtheconfigurationfilesinJenkinsPipelines

    I came up with this:

    configFileProvider([configFile(fileId: 'my-settings-file-id', targetLocation: 'my-settings-override.xml', variable: 'MVN_SETTINGS')]) {
                    // optional run script and use ${MVN_SETTINGS}
    }
    

    And further down I could reference my-settings-override.xml which has been copied to the root of my workspace. Ideally you run your maven commands from within the configFileProvider block, but we needed to pass it to an osgi container that is used for integration tests.