Search code examples
gitlab-ci

How can I test gitlab-ci.yml?


I've finally manage to make it work so that when you push to a branch job would launch, but I keep waiting for it to launch around 3min and then I've got errors which I need to fix and then commit again, and then waiting again. How can I just ssh to that public runner and test .gitlab-ci.yml "script" part just in the bash?


Solution

  • See if GitLab 13.3 (August 2020) could help:

    Better linting for .gitlab-ci.yml files

    When reviewing your CI definitions, you can now use our CI linter to go deeper into pipeline processing to validate the correctness of your .gitlab-ci.yml.

    The CI linter provides feedback not only for syntax validation, but it also validates other kinds of logical errors and invalid configurations by simulating the pipeline as if you were running on master (without actually running anything).

    This helps you produce a properly configured pipeline faster and helps you avoid situations where a pipeline passed the linter but still could not run.

    See Documentation and Issue.

    And, still with GitLab 13.3 (August 2020)

    CI linter now can provide warnings in addition to errors

    The CI linter can now provide warnings in addition to error messages when validating your .gitlab-ci.yml file.

    This gives us the opportunity to provide more guidance when evaluating your pipelines, thereby making it easier to avoid more kinds of mistakes by catching them earlier.

    Our initial iteration is to provide a warning when the when:always rule is used without workflow:rules; this scenario causes duplicate pipelines when an MR is created and has also been a source of confusion.
    And in addition to displaying this new warning message on the linter page, it will also appear on the pipeline view and run pipeline page to help you improve your CI configurations.

    See Documentation and Issue.


    With GitLab 13.8 (January 2021), you can check its validity:

    CI/CD configuration validation in Pipeline Editor

    Previously, to validate your CI/CD configuration, you had to navigate to the CI lint page or commit your changes and look for any errors.

    In this release, we’ve added verification in the pipeline editor itself.

    It continuously checks your pipeline configuration before writing your .gitlab-ci.yml file and provides you with an indicator that your configuration is valid.
    This saves you time and effort that could otherwise be spent optimizing your pipeline.

    https://about.gitlab.com/images/13_8/config_val.png -- CI/CD configuration validation in Pipeline Editor

    See Documentation and Issue.


    See also GitLab 13.12 (May 2021)

    Pipeline status widget in the pipeline editor

    Previously, after committing changes using the pipeline editor, you had to navigate to a different page to know the real time status of your pipeline.

    In this release, we added a pipeline status widget to the pipeline editor so that you can monitor the status of your pipeline without leaving the comfort of the editor.

    https://about.gitlab.com/images/13_12/status.png -- Pipeline status widget in the pipeline editor

    See Documentation and Issue.