I am trying to use the the withMaven step in a jenkins pipeline to deploy 
to a specified repository but I get some errors when using jenkins job 
parameters.


The pipeline script is simple checkout + deploy strategy. Initially I 
specified the OS (used to specify the jenkins agent label) as a variable:

def os = 'windows'

pipeline {
    agent { label "jenkins-agent-${os}" }
    stages {
        stage('Checkout') {
            steps {
                checkout(...)
            }
        }
        stage('Deploy') {
            steps {
                script {
                    def deploymentRepository = 
"my-server-id::default::https://my.server.url/libs-snapshots-local'
                    withMaven(maven:'maven-3.0.5', jdk:'jdk-8u152', 
mavenSettingsConfig:'maven-settings') {
                        bat "mvn -V -U 
-DaltDeploymentRepository=${deploymentRepository}"
                    }
                }
            }
        }
    }
}



This works as expected.

I decided to replace the "os" variable in the pipeline script with a 
jenkins job parameter (a string parameter with name 'os' and default value 
of 'windows'):

pipeline {
    agent { label "jenkins-agent-${params.os}" }
    ...



But running this now gives the following error:

c:\Jenkins\workspace\deployer>mvn -V -U 
-DaltDeploymentRepository=my-server-id::default::https://my.server.url/libs-snapshots-local
 clean deploy 

----- withMaven Wrapper script -----

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 
23:51:28+1000)

Java version: 1.8.0_152, vendor: Oracle Corporation

OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "dos"

[INFO] Scanning for projects...

Downloading: 
https://my.server.url/libs-snapshots-local/plugins-releases/my-server-id/default/https/default-https.pom
 
<https://brisbaneart.ap.cat.com/artifactory/mstar-office-maven-plugins-releases/connectedworksite-maven-repo/default/https/default-https.pom>

Downloading: *https://* 
<https://brisbaneart.ap.cat.com/artifactory/mstar-office-maven-plugins-snapshots/connectedworksite-maven-repo/default/https/default-https.pom>

my.server.url/libs-snapshots-local/ 
<https://brisbaneart.ap.cat.com/artifactory/mstar-office-maven-plugins-snapshots/connectedworksite-maven-repo/default/https/default-https.pom>

plugins-snapshots/my-server-id/default/https/default-https.pom 
<https://brisbaneart.ap.cat.com/artifactory/mstar-office-maven-plugins-snapshots/connectedworksite-maven-repo/default/https/default-https.pom>

[WARNING] The POM for connectedworksite-maven-repo:default:jar:https is 
missing, no dependency information available



Note that maven is now trying to download a plugin artifact with 
groupId=my-server-id, artifactId=default, and version=https/default-https.

I tried removing the layout from the deployment repository (e.g. to 
-DaltDeploymentRepository=my-server-id::
https://my.server.url/libs-snapshots-local) but got a similar error of 
maven attempting to download a non-existent plugin:

[ERROR] Error resolving version for plugin 'my-server-id:https' from the 
repositories


However if I bump the maven version from 3.0.5 to 3.3.9 (for example) then 
the deployment works as expected.

So there seems to be an issue with the maven version and using jenkins job 
parameters (fails with maven 3.0.5, works with maven 3.3.9) and I'm 
wondering whether this is an issue with maven 3.0.5 (doubtful, as 
specifying the os as a variable works), or with the maven integration 
plugin (perhaps it uses a 'params' variable), or something else (a jenkins 
internal issue). 

I have old projects that are required to use maven 3.0.5 for compatibility 
reasons and I'd really like to parameterize my jenkins jobs if possible.

Any help appreciated.

Using:
- jenkins version 2.190.1
- pipeline maven integration plugin version 3.8.2

-- 
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/0041f9f3-0c07-4f64-8e43-a0e4f70853e8%40googlegroups.com.

Reply via email to