Issue with GOCD Environment Variables in Maven settings.xml

364 views
Skip to first unread message

ShaneG

unread,
Nov 30, 2017, 9:18:15 AM11/30/17
to go-cd
I am using GOCD Docker agents and have created my own docker agent image based on gocd/gocd-agent-centos-7:v17.11.0, and have added Java SDK & Maven, and a custom maven settings.xml

I have a artifact repository that i must authenticate with so in my settings.xml i have added the following section.

    <server>
      <id>my-artifact-repo-name</id>
      <username>${GO_REPO_USER}</username>
      <password>${GO_REPO_PASSWORD}</password>
    </server>

From my GOCD pipeline i have added environment variables for GO_REPO_USER and GO_REPO_PASSWORD.

The GO_REPO_USER is always injected as expected but GOCD seems to think the password is encrypted and is always looking for a settings-security.xml.

I see the following error on the console

[DEBUG] Failed to decrypt password for server my-artifact-repo-name: org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: java.io.FileNotFoundException: /home/go/.m2/settings-security.xml (No such file or directory)
org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: java.io.FileNotFoundException: /home/go/.m2/settings-security.xml (No such file or directory)

If i update the settings.xml with <password>my-password</password> instead of the password i entered as environment variable then it will authenticate fine.

Any help appreciated

Ashwanth Kumar

unread,
Nov 30, 2017, 9:36:21 AM11/30/17
to go...@googlegroups.com
From the maven documentation you might have to give the environment variable as "${env.GO_REPO_PASSWORD}". 

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ashwanth Kumar / ashwanthkumar.in

ShaneG

unread,
Nov 30, 2017, 10:16:26 AM11/30/17
to go-cd
I did try that and it wouldn't retrieve the value, t works fine for ${GO_REPO_USER} so i can't see why it would be any different for ${GO_REPO_PASSWORD}

To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ketan Padegaonkar

unread,
Nov 30, 2017, 10:19:54 AM11/30/17
to go...@googlegroups.com
On Thu, Nov 30, 2017 at 8:46 PM ShaneG <galvi...@gmail.com> wrote:
I did try that and it wouldn't retrieve the value, t works fine for ${GO_REPO_USER} so i can't see why it would be any different for ${GO_REPO_PASSWORD}

Maybe a typo in environment variable name, or perhaps a special character in the password needs xml escaping?

ShaneG

unread,
Nov 30, 2017, 11:08:11 AM11/30/17
to go-cd
Good suggestion, but no everything looks ok from that point of view

Aravind SV

unread,
Dec 1, 2017, 7:11:27 AM12/1/17
to go...@googlegroups.com
Hello ShaneG,

On the command-line, if you do this:

export GO_REPO_PASSWORD=abcde
mvn ...

... does it work?

Since this error is coming from Maven and not GoCD, I'm wondering whether the environment variable is not expanded by Maven. Braces are special in the <password> field in settings.xml as you can see from here. So, my guess is that the "$" is ignored and the braces are considered to be part of an encrypted password.

Cheers,
Aravind


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages