Skip to content
Snippets Groups Projects

Enable CI for gitlab when .gitlab-ci.yml is pushed

Merged username-removed-444 requested to merge enable-ci-on-push into master

Make enabling CI as easy as pushing file.

Should be merged after !1402 (merged).

Fixes #2650 (closed). Part of #2594 (closed) and internal issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2528

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @DouweM review? Please! 😃

    Edited by username-removed-444
  • username-removed-444 mentioned in merge request !1405 (merged)

    mentioned in merge request !1405 (merged)

  • Douwe Maan
    Douwe Maan @DouweM started a thread on the diff
  • 55 55
    56 56 @push_data = build_push_data(oldrev, newrev, ref)
    57 57
    58 # If CI was disabled but .gitlab-ci.yml file was pushed
    59 # we enable CI automatically
    60 if !project.gitlab_ci? && gitlab_ci_yaml?(newrev)
    61 project.enable_ci(user)
  • Added 1 commit:

    • 0a57c3f6 - Refactor Project#enable_ci method
  • username-removed-444 mentioned in merge request !1405 (merged)

    mentioned in merge request !1405 (merged)

  • In that case we should probably remove the Enabled checkbox for GitLab CI in services, because after this MR is merged it will no longer have any effect. We could replace it by text saying GitLab CI depends on .gitlab-ci.yml?

    @DouweM No because there will be no way to disable CI.

    Proper way now after this MR:

    • remove .gitlab-ci.yml file
    • disable checkbox

    Also, should we automatically set ci_service.active to false when .gitlab-ci.yml is deleted?

    @DouweM no because some old branches may not have .gitlab-ci.yml. You don't want accidentally disable our CI by pushing to 6-9-stable

    Edited by username-removed-444
  • @DouweM actually we can check if file was in previous commit but was removed in new commit. But I think our problem right now is people who can not easily enable CI - not people who want to disable it.

  • no because some old branches may not have .gitlab-ci.yml. You don't want push to 6-9-stable to disable our CI

    @dzaporozhets Ah yeah, good point.

    Maybe GitlabCiService should always be on, and do a check if .gitlab-ci.yml exists in the branch in question before actually executing. Otherwise, the service could accidentally be enabled again, when someone pushes to a feature branch that was created before .gitlab-ci.yml was deleted in the master branch.

    The issue I have with the proposed behavior is that we will have two things that determine if CI is enabled or not, the checkbox and the .gitlab-ci.yml, that interact with eachother in not completely obvious ways. I would love to just have the presence of .gitlab-ci.yml determine if CI is enabled or not.

  • I would love to just have the presence of .gitlab-ci.yml determine if CI is enabled or not.

    @DouweM makes sense. I propose I will create separate merge request that disable CI if yml existed but removed in main branch. Because I have 2 more merge requests waiting review based on this.

  • @dzaporozhets Sounds good, this MR looks good.

  • mentioned in issue #2714 (closed)

  • mentioned in issue #2715 (closed)

  • username-removed-444 Status changed to merged

    Status changed to merged

  • mentioned in commit b859506b

  • 👍 for the end result!

  • Douwe Maan mentioned in commit a58c6e9a

    mentioned in commit a58c6e9a

  • Please register or sign in to reply
    Loading