GitLab · Create or update a file — Commits a file to a branch — writes text, or a file from an earlier step, to a file in a project's repository, as a commit. It looks for the file first: a new file is created, an existing one replaced.

Who can do this

Workspace Admins and Editors, on every plan. Viewers see the step's settings but cannot change them.

Before you start

A GitLab connection with the api scope, whose user is a Developer or above in the project — Maintainer to commit to a protected branch. See Connect GitLab.

Steps

  1. Select + where the step should go. In the step picker, open Apps, select GitLab, then Create or update a file. Or search GitLab.
  2. In Connection, choose your GitLab connection.
  3. In Project, choose the project — for example consulace/billing-service.
  4. In Path, the file's path in the repository — docs/release-notes.md.
  5. In Content, the text the file should hold — The file's text — or leave it empty and give a file below. Use {{ }} for values from earlier steps.
    • Or under Or a file, select Add a file and drag in a file from an earlier step — A file from an earlier step. When both are given, the file wins.
  6. In Branch, choose the branch — main.
  7. In Commit message, type the message.
  8. Select Run this step to try it. This makes a real commit.

Output

Field What it is
path The file's path.
branch The branch it was committed to.
created true when the file was new, false when it replaced one.

Good to know

  • It replaces the whole file. It does not add to the end.
  • Any file. A file from an earlier step — a picture, a PDF, a zip — is committed as it is.
  • The branch must exist. The step does not make a new branch.
  • With Content empty and no file, the file is committed empty.
  • Each item runs the step once. Ten items make ten commits.

If something goes wrong

What you see Why What to do
Path is empty when the step ran — an earlier step may not have given the value it names. The path came out empty. Check the values it reads.
Branch is empty when the step ran — … / Commit message is empty … A required value is empty. Fill it in.
GitLab refused: You are not allowed to push into this branch. Check the connection's details on Connections. The branch is protected. Commit to another branch, then use Create a merge request.
GitLab refused: 403 Forbidden. Check the connection's details on Connections. The token's user cannot write to the project. Give the user the Developer role or above.
GitLab refused: 404 Project Not Found. The token cannot see the project. Check the token's user is a member.