Search code examples
gitlabgitlab-cipipeline

Gitlab: is it possible to pass an SQL script when manually running pipelines?


Sometimes I need to make a changes to the DB that do not fall into migrations idea (migrations are about changing schema, but I need to manipulate data itself).

So I'm thinking about an additional pipeline that I can start manually, but provide a raw sql file to it beforehand. Gitlab seem to have such an option - it provides a File variable type, but there is no file input next to it.

enter image description here

Is it possible to make it work as I imagined?


Solution

  • is it possible to pass an SQL script when manually running pipelines?

    Yes it is possible, just pass the script as an environment variable. You can pass any text, so any data.

    it provides a File variable type, but there is no file input next to it.

    See documentation https://docs.gitlab.com/ee/ci/variables/#use-file-type-cicd-variables .

    File type variables:
    Consist of a key, value, and file.
    Are made available in jobs as environment variables, with:
        The CI/CD variable key as the environment variable name.
        The CI/CD variable value saved to a temporary file.
        The path to the temporary file as the environment variable value.