How to specify svn credentialsId in pipeline job?

1,961 views
Skip to first unread message

David Aldrich

unread,
Apr 19, 2017, 7:19:15 AM4/19/17
to jenkins...@googlegroups.com
Hi

I have created a simple pipeline job that is intended just to check out a working copy from svn initially.

Here's the script:

node {
echo 'Hello World'

stage('Checkout') {
checkout([$class: 'SubversionSCM',
additionalCredentials: [],
excludedCommitMessages: '',
excludedRegions: '',
excludedRevprop: '',
excludedUsers: 'buildbot',
filterChangelog: false,
ignoreDirPropChanges: false,
includedRegions: '',
locations: [[credentialsId: 'b86bc2b6-994b-4811-ac98-0f35e9a9b114',
depthOption: 'infinity',
ignoreExternalsOption: true,
local: '.',
remote: "<snip>"]],
workspaceUpdater: [$class: 'UpdateUpdater']])
}
}

Is the script valid?

How do I determine the 'credentialsId' ? (I have credentials set up in non-pipeline jobs already).

Best regards

David

thomas....@teamaol.com

unread,
Apr 20, 2017, 6:38:40 AM4/20/17
to Jenkins Users, David....@emea.nec.com
Usually the adminstrator of a Jenkins is reponsible to register credentials
with a useful (readable) name. If those admin forget to give a name Jenkins
does it for your which results usually in something like this: "b86bc2b6-994b-4811-ac98-0f35e9a9b114'

Of course you don't wanna have such ID's in your coded pipeline. Consider
you might have running your pipeline on different Jenkins providing the same
credentials (names) your project should be able to build without code changes.

It might be a permission thing that you cannot see the credentials.

David Aldrich

unread,
Apr 20, 2017, 6:59:31 AM4/20/17
to thomas....@teamaol.com, Jenkins Users

Thanks for your reply. I am an admin so I should be able to see everything.  Where should I look for the credentials?

 

All our conventional jobs use the following credential seen on the job configuration page:

 

 

Where should I look for the corresponding credentialId?

 

Best regards

 

David

 

Click here to report this email as spam.

thomas....@teamaol.com

unread,
Apr 20, 2017, 7:07:53 AM4/20/17
to Jenkins Users, thomas....@teamaol.com, David....@emea.nec.com
When you click top/left on "Jenkins" (navigate to the mainpage) the link to the credentials
should appear on the left side (short before build queue).

thomas....@teamaol.com

unread,
Apr 20, 2017, 7:10:31 AM4/20/17
to Jenkins Users, thomas....@teamaol.com, David....@emea.nec.com
Click on the link an a table is shown and there is the columns ID ...
One note: if you forgot to provide a readable name you cannot change it. You have to re-create it then.

David Aldrich

unread,
Apr 20, 2017, 7:13:20 AM4/20/17
to thomas....@teamaol.com, Jenkins Users

Thanks, I see it now. The credential does have a readable name.  Can I assign that name to credentialsId or should it be assigned to a different property?

thomas....@teamaol.com

unread,
Apr 20, 2017, 7:47:36 AM4/20/17
to Jenkins Users, thomas....@teamaol.com, David....@emea.nec.com
You assing it to the parameter credentialsId.

David Aldrich

unread,
Apr 20, 2017, 11:28:51 AM4/20/17
to thomas....@teamaol.com, Jenkins Users

Hi Thomas

 

The credentialsId is now working fine for me, thanks for your help.

 

However, my svn checkout involves an external, which is not appearing in the workspace.  I guess I need to specify ‘additional credentials’.  I tried:

 

stage('Checkout') {

    checkout([$class: 'SubversionSCM',

        additionalCredentials: [credentialsId: '086c0d1a-15e7-4cea-9702-7528ac021fab'],

        excludedCommitMessages: '',

        excludedRegions: '',

        excludedRevprop: '',

        excludedUsers: 'buildbot',

        filterChangelog: false,

        ignoreDirPropChanges: false,

        includedRegions: '',

        locations: [[credentialsId: '086c0d1a-15e7-4cea-9702-7528ac021fab',

            depthOption: 'infinity',

            ignoreExternalsOption: true,

            local: '.',

            remote: "https://172.29.68.12/subversion/Leda/trunk/"]],

        workspaceUpdater: [$class: 'UpdateUpdater']])

}

 

But that failed. I think my setting for additionalCredentials is wrong.  Can you help me correct the syntax please?

David Aldrich

unread,
Apr 20, 2017, 11:50:06 AM4/20/17
to thomas....@teamaol.com, Jenkins Users

The snippet generator has solved this for me:

 

additionalCredentials: [[credentialsId: '<snip>', realm: '']],

 

From: David Aldrich
Sent: 20 April 2017 16:29
To: 'thomas....@teamaol.com' <thomas....@teamaol.com>; Jenkins Users <jenkins...@googlegroups.com>
Subject: RE: How to specify svn credentialsId in pipeline job?

 

Hi Thomas

 

The credentialsId is now working fine for me, thanks for your help.

 

However, my svn checkout involves an external, which is not appearing in the workspace.  I guess I need to specify ‘additional credentials’.  I tried:

 

stage('Checkout') {

    checkout([$class: 'SubversionSCM',

        additionalCredentials: [credentialsId: '086c0d1a-15e7-4cea-9702-7528ac021fab'],

        excludedCommitMessages: '',

        excludedRegions: '',

        excludedRevprop: '',

        excludedUsers: 'buildbot',

        filterChangelog: false,

        ignoreDirPropChanges: false,

        includedRegions: '',

        locations: [[credentialsId: '086c0d1a-15e7-4cea-9702-7528ac021fab',

            depthOption: 'infinity',

            ignoreExternalsOption: true,

            local: '.',

            remote: "https://172.29.68.12/subversion/Leda/trunk/"]],

        workspaceUpdater: [$class: 'UpdateUpdater']])

}

 

But that failed. I think my setting for additionalCredentials is wrong.  Can you help me correct the syntax please?

 

Best regards

Reply all
Reply to author
Forward
0 new messages