project quickstart tries to use GitHub credentials even when 'bitbucketcloud' is specified
Voyen opened this issue ยท 11 comments
Summary
After creating infrastructure and cluster successfully within AWS/BitBucketCloud, running jx project quickstart
(or import or anything similar) fails due to credentials issues.
Steps to reproduce the behavior
Run jx project quickstart --git-kind bitbucketcloud --git-server https://bitbucket.org --git-token <token here> --git-username <username here>
Expected behavior
Step through CLI questions and new project gets added to BitBucket as a new repository
Actual behavior
Even though --git-username and --git-token are specified, the CLI still asks for both of these, then fails.
Username for 'https://bitbucket.org': <username here>
Password for 'https://jenkins_complexica@bitbucket.org': <token here>
? select the quickstart you wish to create: spring-boot-rest-prometheus-java11
WARNING: Please make sure that the file '$HOME/git/credentials' containes a valid API token in the format 'https://<Username>:<Personal Access Token>@github.com'
error: failed to find the organisations: failed to list git organisations for user <username here>: Not Authorized
Note that it's expecting the credentials to end in @github.com even though bitbucketcloud was specified as a parameter.
Jx version
The output of jx version
is:
version: 3.1.292
Diagnostic information
The output of jx diagnose version
is:
Error: unknown command "diagnose" for "jx"
Run 'jx --help' for usage.
Kubernetes cluster
Created using Terraform (based on provided AWS template repository), Kubernetes version 1.17.
Kubectl version
The output of kubectl version --client
is:
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"archive", BuildDate:"2021-01-13T22:07:54Z", GoVersion:"go1.15.6", Compiler:"gc", Platform:"linux/amd64"}
Operating system / Environment
Linux 5.11.7-arch1-1
I am also running into an issue related to jx-project with bitbucketcloud but doesn't look like the issue is because of auth. It appears to me that the jx-project is NOT including the username as part of the URL for cloning the repository. URL as expected by bitbucketcloud --> https://USERNAME@bitbucket.org/ORGNAME/REPONAME.git
This is a showstopper for me to move forward with Jenkins-x and BitbucketCloud.
Is there any work around? thanks.
I'm having the same problem.
Steps to reproduce the behavior
Run jx create quickstart --git-username <username> --git-token <token> --git-server https://bitbucket.org --git-kind bitbucketcloud --verbose
Actual behavior
DEBUG: using git kind bitbucketcloud server https://bitbucket.org and user <username>
DEBUG: loading git credentials file /home/user/git/credentials
DEBUG: cloning https://bitbucket.org/<repo>.git to directory /tmp/jx-git-493100870
DEBUG: about to run: git clone https://bitbucket.org/<repo>.git /tmp/jx-git-493100870 in dir /tmp
Username for 'https://bitbucket.org': <username>
Password for 'https://<username>@bitbucket.org':
DEBUG: Cloning into '/tmp/jx-git-493100870'...
? select the quickstart you wish to create: aspnet-app
WARNING: Please make sure that the file '$HOME/git/credentials' containes a valid API token in the format 'https://<Username>:<Personal Access Token>@github.com'
error: failed to find the organisations: failed to list git organisations for user <username>: Bad Request
Jx version
jx version
version: 3.1.353
Kubernetes version
kubectl version --client
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Did anyone get around this? I have the same issue, with a github repo tho.
$ jx version
version: 3.2.196
EDIT: Got it working by providing my github username again and pasted the token instead of the password.
facing this issue with bitbucket cloud as well
/assign
So the warning message was hardcoded, and has nothing to do with jx trying to search for github credentials when end users are using bitbucket/gitlab. This is fixed here: jenkins-x-plugins/jx-project#466
However, this PR just fixes the wording of the warning message, I still get the same error as described in the issue.
I created a ~/git/credentials file and added my username and password to it in the format: https://username:password@bitbucket.org (password is the app password)
and I got the error:
error: failed to find the organisations: failed to list git organisations for user username: Forbidden
Digging a bit deeper, seems like we call the deprecated/removed teams endpoint instead of workspaces.
I tried both the end points:
- workspaces and teams with old password with less privileges
curl -u username:password https://api.bitbucket.org/2.0/workspaces
{"type": "error", "error": {"message": "Your credentials lack one or more required privilege scopes.", "detail": {"granted": ["webhook", "issue:write", "pullrequest:write", "repository:admin", "project:write"], "required": ["account"]}}}%
- Created a new app password with account read access, and workspaces worked, but team did not work.
{"type": "error", "error": {"message": "This endpoint has been removed. See our documentation for more information. https://developer.atlassian.com/cloud/bitbucket/rest/api-group-teams/#api-teams-get"}}%
However, I still got bad request, which is because by default jx sets pagination size at 500, which exceeds bitbucket cloud's global max value of 100.
Those issues are fixed in this PR: jenkins-x/go-scm#319
If someone can give it a try, and let me know if the issue has been fixed, it would be helpful (the fix will be in jx v3.2.253).
I will look at other bitbucket cloud issues in the meantime.
Tip: If you see forbidden error, try to curl the bb cloud APIs directly, most probably the app password has less access. I will update the docs soon!
@ankitm123 I'm still experiencing this issue in version jx v3.2.256. I am trying to use github. See the following command output:
โ jx project quickstart
? select the quickstart you wish to create: golang-http-from-jenkins-x-yml
WARNING: Please make sure that the file '$HOME/git/credentials' contains a valid API token in the format 'https://<Username>:<Personal Access Token>@gitserverurl' where gitserver can be github.com, gitlab.com, bitbucket.org etc
error: failed to find the organisations: failed to list git organisations for user frandelgado: Unauthorized
I checked that my acess token has full access to orgs and yet, the error persists. I even checked that I can list the orgs manually:
โ curl https://api.github.com/users/fdelgado/orgs
[
]
I think maybe the path is wrong at: https://github.com/ankitm123/go-scm/blob/main/scm/driver/github/org.go#L120
I think it should be users/
and not user/
, check out the following:
~/repos/jx-demo-project
โ curl https://api.github.com/user/membership/orgs
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
~/repos/jx-demo-project
โ curl https://api.github.com/users/membership/orgs
[
]
After the update I no longer get Unauthorized
errors (on bitbucketcloud), however now I'm getting this error:
Pushed Git repository to https://bitbucket.org/REDACTED/REDACTED
error: failed to add and accept collaborator: failed to list invites: Not Supported
this happens after selecting the catalog folder
Gitlab user here. When I try to do a x project quickstart
I get an error: failed to add and accept collaborator: failed to list invites: Not Supported
โฏ jx project quickstart
? select the quickstart you wish to create: php-helloworld
? git owner: myorg
? git repository name: php-helloworld
Creating repository banyan-security/php-helloworld
not sending git token to download quickstart from https://codeload.github.com/jenkins-x-quickstarts/php-helloworld/zip/386ed8293 as its using a different domain to the git token
Generated quickstart at /Users/user/src/jx3-gke-gsm/php-helloworld
Created project at /Users/user/src/jx3-gke-gsm/php-helloworld
? Would you like to initialise git now? Yes
? Commit message: chore: initial import
Git repository created
performing pack detection in folder /Users/user/src/jx3-gke-gsm/php-helloworld
--> Draft detected PHP (76.495726%)
? Confirm the catalog folder you wish to use on this project php
selected catalog folder: php
Pushed Git repository to https://gitlab.com/myorg/php-helloworld
error: failed to add and accept collaborator: failed to list invites: Not Supported
Any ideas?
Hi, I just ran a small demo with two colleagues and they both see this error, using github. These had never used Jx before, fresh installs, on windows.
error: failed to add and accept collaborator: failed to list invites: Not Supported