Search code examples
azure-devopstfsdevopstekton-pipelinesopenshift-pipelines

fatal: could not read password for 'https://[PAT]@tfs.**.com' no such device or address


I'm building a Tekton task on Openshift pipelines and trying to clone the source code from my GIT repository. I'm cloning the repo in my script using the below

git clone 'https://[PAT]@tfs.**.com/[org]/[project]/_git/[repo]'

but always getting the error below

fatal: could not read password for 'https://[PAT]@tfs.**.com' no such device or address

I created a secret with the username and password(PAT) and added the secret to pipeline service account but still getting the same error. I searched a lot about the issue and nothing from all the solutions I found worked with me.


Solution

  • When you are accessing protected github repo from Openshift pipelines check the following (I'm using the built in git-clone cluster task):

    • make sure you have secret in your current project similar to this:
    kind: Secret
    apiVersion: v1
    metadata:
      name: git-token
      annotations:
        tekton.dev/git-0: 'https://yourrepo.com'
    stringData:
      password: YOURTOKEN
      username: anything
    type: kubernetes.io/basic-auth
    

    https:// in annotation is critical, I had the same error as you when I just had hostname.

    • make sure your token is added to the pipeline service account in secret section, similar to this:
    secrets:
      - name: pipeline-dockercfg-tqdxx
      - name: git-token