How To: Switch Git Context from OAuth to PAT
Overview
Currently, the git context is set to OAuth but would like to use Personal Access Token (PAT) instead.
Details
-
Use the Codefresh CLI to get all available contexts:
codefresh get contexts
- In the output, find the name of the git context you want to update.
- Use the Codefresh CLI to get the YAML version of the git context and save it to a file:
codefresh get context [git-context-name] --decrypt -o yaml > gitContext.yaml
-
Open the file and switch the YAML to the following. The section that needs to be changed is mainly the
spec.data
section.apiVersion: v1 kind: context metadata: default: false system: false name: GITCONTEXT type: git.github spec: type: git.github data: sharingPolicy: AllUsersInAccount auth: type: basic password: ghp_xxxxxxxxxxxxxxxxxxxxxxxxx behindFirewall: false sshClone: false secretStoreReferences: []
- Save the File
- Use the Codefresh CLI to patch the git context
codefresh patch context -f gitContext.yaml
- Now all pipelines and triggers will use PAT instead of OAuth.