jstastny-cz opened a new issue, #772:
URL: https://github.com/apache/incubator-kie-issues/issues/772
Currently githubscm methods work with either credentials_id or
token_credentials_id.
The real difference between the value is that credentials_id is
username:password pair, whereas token_credentials_id is just string token.
Moreover since GitHub stopped accepting passwords for authentication, in fact
the username:password pair is currently username:token - thus the value hold by
token_credentials_id is typically contained and accessible in matching
credentials_id value.
This task should entail research of all applicable usages in githubscm (and
pipelines using it) and evaluation if all can be replaced by credentials_id
username:token pair.
It would simplify constructs as:
```
def checkoutIfExists(String repository, String author, String branches,
String defaultAuthor, String defaultBranches, boolean mergeTarget = false, def
credentials = ['token': 'kie-ci1-token', 'usernamePassword': 'kie-ci']) {
assert credentials['token']
assert credentials['usernamePassword']
def sourceAuthor = author
def sourceRepository = getForkedProjectName(defaultAuthor, repository,
sourceAuthor, credentials['token']) ?: repository
// Checks source group and branch (for cases where the branch has been
created in the author's forked project)
def repositoryScm = getRepositoryScm(sourceRepository, author, branches,
credentials['usernamePassword'])
....
```
Notice the selective passing of correct credentials type to individual
method based on how they're implemented.
It should be possible to rewrite the methods expecting token, and instead of:
```
withCredentials([string(credentialsId: credentialsId, variable:
'GITHUB_TOKEN')]) {
```
use
```
withCredentials([usernamePassword(credentialsId: credentialsId,
usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) {
```
And just not using GITHUB_USER env var if not needed. But would simplify the
implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]