jenkins-x / jx

Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
https://jenkins-x.io/
Apache License 2.0
4.58k stars 788 forks source link

About GitHub requires all users to use token authentication #7866

Open alberthuang24 opened 3 years ago

alberthuang24 commented 3 years ago

In today. users of github using the jx import command should get an error like mine

❯ jx import
error: failed to clone dev env git repository: failed to clone dev environment git repository https://github.com/ICodeWorld-Inc/devops.git: failed to clone repository https://github.com/ICodeWorld-Inc/devops.git to directory: /var/folders/gm/l1qgxw0520v1kt5488cxtz5c0000gn/T/jx-git-161209358: failed to run 'git clone https://github.com/ICodeWorld-Inc/devops.git /var/folders/gm/l1qgxw0520v1kt5488cxtz5c0000gn/T/jx-git-161209358' command in directory '/var/folders/gm/l1qgxw0520v1kt5488cxtz5c0000gn/T', output: 'Cloning into '/var/folders/gm/l1qgxw0520v1kt5488cxtz5c0000gn/T/jx-git-161209358'...
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
fatal: unable to access 'https://github.com/ICodeWorld-Inc/devops.git/': The requested URL returned error: 403'

The reason for this seems to be that the https clone dev repo is used here.

Possible solutions

jx admin install support ssh protocol url.

Reference

https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/

alberthuang24 commented 3 years ago

https://github.com/HongjiangHuang/jxboot-helmfile-resources/blob/main/charts/jxboot-helmfile-resources/templates/environments.yaml#L21

I fixed it by temporarily modifying spec.cluster.gitServer.

apiVersion: core.jenkins-x.io/v4beta1
kind: Requirements
spec:
  autoUpdate:
    enabled: false
    schedule: ""
  cluster:
    chartRepository: http://bucketrepo.jx.svc.cluster.local/bucketrepo/charts
    clusterName: kind
    devEnvApprovers:
    - todo
    environmentGitOwner: todo
    gitKind: github
    gitName: github
-    gitServer: https://github.com
+    gitServer: https://<your github token>@github.com
    provider: kubernetes
    registry: ghcr.io
jrx-sjg commented 3 years ago

Cannot believe passing the raw token on a repository is the unique solution to this. Unbelievable.

danielosg commented 2 years ago

Agree with you @jrx-sjg

ankitm123 commented 2 years ago

jx admin install support ssh protocol url.

Will take a look this holidays. It would be good to use ssh keys to do the git operations

A bit confused though, u should not have to specify access token in the requirements file. Check: https://jenkins-x.io/v3/develop/faq/using/#how-do-i-stop-jx-asking-for-git-credentials

May be I am missing something?