Arnold van Wijnbergen
unread,Oct 30, 2022, 4:34:01 PM10/30/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Jenkins Developers
Hi Jenkins Developers,
We are currently busy with adding a new feature to OSS code signing plugin. In the current situation we store credentials (username/password) as global in Jenkins as credentials provider. For this we use the credentials plugin.
This works well, but we want to improve this to support FolderCredentialsProvider used in combination with the Role strategy plugin. Currently this works okay.
1) First step we moved UI code to the simplebuildStep. This works and we can choose and save the folder based 'global' credential. We can see this credential in the dropdown list. So this UI and persistence part works.
Now the second part is where we see some problems occur when we execute the job. The job is inside the folder we created the credentials.
2) When we now execute the job we use following code to lookup the credential by credentialId.
@Nullable
public static StandardUsernamePasswordCredentials findCredentials(String credentialsId) {
return findCredentials(credentialsId, null);
}
@Nullable
public static StandardUsernamePasswordCredentials findCredentials(String credentialsId, Item item) {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
return CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class,
item,
ACL.SYSTEM,
Collections.emptyList()),
CredentialsMatchers.allOf(
CredentialsMatchers.withId(credentialsId),
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class))));
}
This code executes but throws an exception (as defined by us) that the credentialID is not found. I can see that this ID corresponds to the folder based credential.
When updating the configuration with a Jenkins global credential everything works.
To summarise : Seems that we currently still only can see Jenkins global credentials instead of folder global credentials we want to include as well.
We already tried to look deeper into credentials API, but don't find a good hint, so looking for a suggestion here. The job is started by an admin user and running as SYSTEM.
How can we include both Jenkins and folder provider credentials in the lookup, so both can be matched ? Currently the folder credentials are not found.
Any help here is welcome. I think we just oversee something here