16

I have a Jenkins cluster that is shared by several teams, that I can configure build jobs on, However i can't easily make changes to the Jenkins configuration itself.

There is a central "nexus pro" maven repository manager but each team / group in this very large multinational has their own repo, publishing to the repos requires username / password combination.

This means that I have to configure the Jenkins server with a maven settings.xml that is unique to the team I am working with without messing up the maven configuration of the other users of the Jenkins cluster.

Git is the source control repository.

  1. On a shared Jenkins cluster how do I configure a maven settings.xml that is unique to a a group of build jobs or to a single job? What are the best practices for handling this type of situation?
ams
  • 60,316
  • 68
  • 200
  • 288

6 Answers6

20

I would recommend using the configuration file plugin, provides a UI to edit one or more Maven settings files.

These settings files can be passed into your Maven build using the "-s" option.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • with this plugin, how can I find the name to provide into -s? – Andrii Plotnikov Mar 27 '17 at 14:24
  • The configuration file plugin enables you to create a Maven settings file via the Jenkins admin screens. This file's path will then be automatically passed to your Maven build step if you select it from the build job. – Mark O'Connor Mar 29 '17 at 17:39
  • If you use Nexus Pro for your maven repo its worth looking down at RCross's answer below – user1084563 Aug 03 '17 at 19:04
2

You can specify for each job in the Maven Advanced Options part a specific seetings.xml path

yodamad
  • 1,452
  • 14
  • 24
  • 2
    the issue is getting the settings.xml onto the jenkins server in the first place as I don't have shell access to the jenkins machine. – ams May 22 '13 at 12:34
  • maybe you can try to add settings.xml to your workspace file and use jenkins variables (like JENKINS_HOME) to set the path to the workspace. Another idea, is that you can configure in global settings the method for settings.xml to be use and if I remember well, you can define it as "workspace relative" – yodamad May 22 '13 at 14:41
2

We manage all our build nodes using Puppet. It gives you greater control than just settings.xml. Highly recommended

Puppet is IT automation software that helps system administrators manage infrastructure throughout its lifecycle, from provisioning and configuration to patch management and compliance. Using Puppet, you can easily automate repetitive tasks, quickly deploy critical applications, and proactively manage change, scaling from 10s of servers to 1000s, on-premise or in the cloud.

Hilikus
  • 9,954
  • 14
  • 65
  • 118
1

If your company is using Nexus Pro (as you've already mentioned), then your unique Maven settings.xml can be stored there, and retrieved at build time using the nexus-maven-plugin as described here: http://books.sonatype.com/nexus-book/reference/maven-settings.html

Combined with token-based access (again, Nexus Pro does this), you do not need to store passwords insecurely in the settings.xml (see https://books.sonatype.com/nexus-book/reference/usertoken.html)

user1084563
  • 2,149
  • 17
  • 28
RCross
  • 4,919
  • 4
  • 44
  • 42
1

I faced the similar issue when building the project with jenkins as ojdbc jar is not available in maven central repository.

It worked when I placed the ojdbc jar in WEB-INF/lib folder and removed the maven dependency in pom.xml.

octobus
  • 1,246
  • 1
  • 14
  • 20
0

A good way to automate the provisioning of maven executors with specific configuration, is using ElasticBox Jenkins plugin.

You only need to create a box for the Maven slave, that define all the customization variables and files to be used by it and choose your preferred cloud provider for deploying it.

ElasticBox gives you also the flexibility to create new slaves only when needed and automatically destroy them after an specified retention time.

Here is how-to connect your Jenkins with ElasticBox:

https://elasticbox.com/documentation/integrate-with-jenkins/jenkins-elasticbox-setup/#jenkins-configure-plugin

Here is how to automate creation of Jenkins slaves with ElasticBox:

https://elasticbox.com/documentation/integrate-with-jenkins/jenkins-elasticbox-slaves/

There is a blog post about how easily build and deploy from GitHub pull requests with ElasticBox Jenkins plugin:

https://elasticbox.com/blog/github-pull-requests-jenkinsplugin/