Cloudbees Jenkins on Kubernettes Maven Integration
For CJOC running on EKS cluster could you please advise the best way to set up intregration for maven.
We would like to set up maven installation on the Jenkins server so that we can have our global settings.xml defined there with other configurations as well as needed.
Any help or suggestions here would be greatly appreciated as always.
Cheers,
Ashley
-
Once you create a Team Master or Managed Master. The Config File Provider plugin can be used on this master to define the configs, which then can be consumed by other plugins like for example Pipeline Maven Plugin
1 -
The config file provider plugin works only if you have settings.xml but if you plan to use settings-security.xml seems like there is no way to do that.
0 -
Using the settings-security.xml and the maven encryption is less interesting if you just inject the server entries in the settings.xml using credentials? The config is created the time of the build and deleted after.
0 -
i am trying to use jenkins scripted pipeline to invoke this config file provider plugin along with fetching credentials from jenkins for the username and password, but the below doesn't seem to work.
stage('Deploy'){ withCredentials([usernamePassword(credentialsId: 'xyz', passwordVariable: 'Password', usernameVariable: 'Username')]) { configFileProvider( [configFile(fileId: 'abcde', variable: 'MAVEN_SETTINGS')]) { sh "'${mvnHome}/bin/mvn' -s $MAVEN_SETTINGS deploy -Dserver.username=${env.Username} -Dserver.password=${env.Password}" } } }
where server.username are defined as properties under settings.xml server section for username and password.
It doesn't even work with :-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'xyz', usernameVariable: 'Username', passwordVariable: 'Password'
Could you please advise how to resolve this?
0 -
It will be easier to use the Maven Pipeline plugin : https://plugins.jenkins.io/pipeline-maven
node{ stage ('Build') { git url: 'https://github.com/cyrille-leclerc/multi-module-maven-project' withMaven( // Maven installation declared in the Jenkins "Global Tool Configuration" maven: 'M3', // Maven settings.xml file defined with the Jenkins Config File Provider Plugin // Maven settings and global settings can also be defined in Jenkins Global Tools Configuration mavenSettingsConfig: 'my-maven-settings', mavenLocalRepo: '.repository') { // Run the maven build sh "mvn clean install" } // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs reports... } }
For the credentials you are configuring them where you define the configuration file in the config file provider side
https://plugins.jenkins.io/config-file-provider
0 -
We have to somehow invoke credentials in the scripted JenkinsFile ( scripted and not declarative) from Jenkins Credentials and since we host maven settings.xml, on cloudbess Jenkins using config file provider plugin, so any mvn commands in the pipeline script require us to declare ConfigFileProvider section and that when coupled with withCredentials to pull credentials from Jenkins and store them under variables so that those could be added as maven arguments for build or deploy, etc, just doesn’t work. May be the syntax is incorrect or there is no proper documentation on how to use credentials from Jenkins in a scripted pipeline( works well in declarative pipeline though)
Any thoughts/suggestions??0 -
This has been resolved using :-
stage('Deploy'){ def usernameLocal, passwordLocal withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'xyz', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME']]) { usernameLocal = env.USERNAME passwordLocal = env.PASSWORD configFileProvider( [configFile(fileId: '**********', variable: 'MAVEN_SETTINGS')]) { sh "'${mvnHome}/bin/mvn' -s $MAVEN_SETTINGS deploy -Dserver.username='${usernameLocal}' -Dserver.password='${passwordLocal}'" } } } 0
Please sign in to leave a comment.
Comments
7 comments