Use this action to set up a Git global configuration for use in CloudBees workflows. This action authenticates the current user, by default scoped to repositories in the same organization as the workflow repository. After this step is run, all steps using the Git CLI in the same job authenticate with these credentials.
You can use this action to avoid failures due to lack of pre-authentication of private repositories. For example, if you are building a Go module that depends on other private modules, private repository authentication must be already in place for go mod download to run successfully.
|
This action may set up authentication for different types of Git global configurations, including:
CloudBees recommends that if you are using a Git client other than the official Git CLI, make sure that your Git client supports the authentication configuration applied by this action. |
All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
Input name | Data type | Required? | Description |
---|---|---|---|
|
String |
Yes |
The token to configure. |
|
String |
Required if |
The repositories accessible via the token.
For listing multiple repositories, CloudBees recommends using a line break separator, although the |
|
String |
CloudBees recommends specifying |
The source code management (SCM) provider. |
|
String |
No |
The GitHub server URL. |
|
String |
No |
The Bitbucket server URL. |
|
String |
No |
The GitLab server URL. |
Usage examples
Use this action to configure a Git token from a secret. This action does not currently work with configuring an SSH private key from a secret, or using CloudBees platform authentication.
Configure a token for all repositories in the same organization
Use a token for all repositories in the same organization as the workflow repository.
For example, the action is run from https://github.com/example/myjob
repository, then the personal access token is configured for all repositories in the https://github.com/example
organization.
In your YAML file, add:
- name: Git global credentials uses: cloudbees-io/configure-git-global-credentials@v1 with: token: ${{ secrets.MY_TOKEN }}
Configure a token for specific repositories in the same SCM provider
Use a token for only the named repositories in the same SCM provider as the workflow repository.
In your YAML file, add:
- name: Git global credentials uses: cloudbees-io/configure-git-global-credentials@v1 with: token: ${{ secrets.MY_TOKEN }} repositories: | example/foo example/bar
Configure a token for all repositories in a different SCM provider
Use a token for all repositories in a named organization in a different SCM provider from that of the workflow repository.
In your YAML file, add:
- name: Git global credentials uses: cloudbees-io/configure-git-global-credentials@v1 with: token: ${{ secrets.MY_GITLAB_TOKEN }} provider: gitlab repositories: example/*
Configure a token for a GitHub Enterprise Server
Use a token for a GitHub Enterprise Server.
In your YAML file, add:
- name: Git global credentials uses: cloudbees-io/configure-git-global-credentials@v1 with: token: ${{ secrets.MY_GHE_TOKEN }} provider: github github-server-url: https://my-ghes-server.example.com repositories: "*/*"
Configure a token for GitHub SaaS, Bitbucket, or GitLab SCM provider instances
Use a token for GitHub SaaS, Bitbucket, or GitLab SCM provider instances.
In your YAML file, add:
- name: Git global credentials uses: cloudbees-io/configure-git-global-credentials@v1 with: token: ${{ secrets.MY_SCM_TOKEN }} provider: bitbucket bitbucket-server-url: https://my-bbdc-server.example.com repositories: "*/*"