Work on Git repositories
Instead of a folder of the node, an agent can work on one or more Git repositories from GitLab or GitHub. The node clones them in each conversation's environment, the agent commits and pushes on a work branch, and opens merge requests (pull requests on GitHub) through Breign.
No Git credential is stored on the node. When Git needs one, the node asks Breign, which only answers for the repositories of the running turn, and only while it runs.
Before you start​
- The agent runs on a node or a node group whose nodes are up to date (they declare Git repositories support). See Execution nodes.
- An administrator has set up at least one way to reach the forge (next section).
- To configure the agent, you need the Update agents permission.
Set up Git access (administrators)​
Open Integrations, then Git access for nodes. Two kinds of identity exist; you can use both.
Members' accounts​
Each member who starts a conversation uses their own GitLab or GitHub account: the agent clones, pushes and opens merge requests as that person, with that person's rights.
- In the forge, create an application:
- GitLab: an OAuth application (Admin › Applications, or a group's settings) with the
api,read_user,read_repositoryandwrite_repositoryscopes. - GitHub: a GitHub App with Contents and Pull requests read/write permissions and expiring user tokens, or an OAuth App.
- GitLab: an OAuth application (Admin › Applications, or a group's settings) with the
- Use the redirect address shown on the page as the application's callback URL.
- In Forges where members connect their account, choose GitLab or GitHub, enter the forge address, the application ID and its secret, then Add the forge.
Members then connect their account in Account settings › Git accounts.
Organization identities​
An organization identity acts the same for everyone who talks to the agent.
- GitLab bot account: a bot account of a GitLab integration. Click Use @bot to make it available. Its personal access token is long-lived: keep it for dedicated repositories.
- GitHub App: an App installed on your GitHub organization, with Contents and Pull requests read/write permissions. Enter its App ID, its Installation ID and its private key (
.pem), plus the GitHub Enterprise address if you use one. Agents get one-hour tokens restricted to the repository they work on.
Connect your account (members)​
- Open Account settings › Git accounts.
- Next to the forge, click Connect and accept on GitLab or GitHub.
- You come back to Breign, connected as @your-username.
Reconnect appears when the forge no longer accepts the token. Disconnect removes the account; agents working on your behalf then stop at the start of their turns.
Configure the agent's repositories​
- Open the agent, then the Execution block, and choose a node or a node group as usual. See Choose where your agent runs.
- Under Workspace, choose Git repositories.
- For each repository:
- Repository URL (HTTPS), for example
https://gitlab.example.com/team/api.git. - Folder: its folder in the environment, filled from the URL.
- Base branch: where the work branch starts and where merge requests go.
- On behalf of: Member who starts the conversation, or an organization identity of the same forge.
- Clone: From the start, or On demand (listed to the agent, cloned only if it needs it).
- Access: Read and write, or Read only.
- Repository URL (HTTPS), for example
- Click Save.
If your own account isn't connected on a repository's forge, the block says so and offers Connect.
Result​
Each conversation gets its own environment on the node: one folder per repository, all on the same work branch breign/<conversation>. Several conversations of the same agent work in parallel without interfering.
The agent knows its repositories and their branches. It commits in each repository, pushes its branch, and uses its Breign tools to open or update a merge request in every changed repository. When several repositories change together, their merge requests link to one another. The agent can also read a merge request's status, pipeline and review comments, and reply.
When a conversation moves to another node, or comes back after its environment was released, it starts again from what was pushed.
Good to know​
- Protect your branches in the forge. The agent can push any branch its identity is allowed to push. Protect
main,devand release branches. - The agent can read the Git token of its turn while the turn runs (it has a shell). The token is limited to the turn's repositories and stops working when the turn ends.
- Read only is a guideline given to the agent; real enforcement comes from the identity's rights in the forge.
- To save disk space, a node removes the dependencies of environments idle for an hour (
node_modules,target…, only what Git ignores); the agent reinstalls them when needed. An environment with work that isn't pushed is never deleted.
If something goes wrong​
- "Connect your Git account on … so the agent can work on its repositories.": connect your account in Account settings › Git accounts, then send your message again.
- "No OAuth application is declared for …": an administrator must add the forge in Integrations, or choose an organization identity for that repository.
- Git repositories can't be chosen ("Requires an up-to-date node"): update Breign Mate or the Breign CLI on the node.
- "Only N of the group's M nodes can clone repositories": the other nodes won't take this agent's turns; update them.
- The turn fails with a repository name: check the URL, the base branch, and that the identity can read the repository.
- "The branch … is not pushed" when opening a merge request: the agent must
git pushfirst; it gets this message and does it.