Re: withMaven step not working with altDeploymentRepository when jenkins job parameters are specified?

19 views
Skip to first unread message

Lee Meador

unread,
Jan 3, 2020, 12:03:16 PM1/3/20
to Jenkins
I might try putting quotes around the value of the defined property as in:

bat "mvn -V -U -DaltDeploymentRepository=\"${deploymentRepository}\""  

On Thu, Jan 2, 2020 at 11:15 PM John Citizen <john.queu...@gmail.com> wrote:
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...
[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-use...@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.


--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com

James Nord

unread,
Jan 4, 2020, 6:58:59 AM1/4/20
to Jenkins Users
'OS' is an environment variable on windows.
the maven scripts are likely looking at it and expecting one that is defined for Windows to set some parameters. the job parameter gets set in the environment for the process in the bat step if I recall correctly and this is likely messing with the script.

try changing 'os' to 'agent-os' and see how you get on.

/James

John Citizen

unread,
Jan 5, 2020, 7:00:39 PM1/5/20
to Jenkins Users
Yes, that was the solution: I replaced the job parameter 'os' with 'agent_os' and the deploy step now works.

Thanks. 
Reply all
Reply to author
Forward
0 new messages