Migrating from Jenkins Ci Service to gitlab-ci.yml

Until now we were using Jenkins to run our build on any feature branch based on the Jenkins CI service. We are currently experimenting with pipelines based on gitlab-ci.yml. As a starting point I would like to limit this only for specific branches that created by few developers as a beta test.

I was trying to avoid merge of .gitlab-ci.yml from feature branches to release branches based on .gitattributes and merge strategies (see here), but this force me to have .gitlab-ci.yml in the release branch. As result gitlab force me to have some valid yml content (I hoped I could at least keep it empty) otherwise I will get invalid yml failure.

Any suggestion on keeping the .gitlab-ci.yml only on feature branch and avoiding manual steps to avoid the merge of .gitlab-ci.yml file until we will adopt it for all branches?

As I don’t actually care to have the .gitlab-ci.yml in release branches as long as the pipelines execute only on selected merge requests. I changed my .gitlab-ci.yml to include a rule. According to the logic below the pipeline will be executed only on merge request with the branch name format FTR-ddddd-g

image: maven-mta:latest
variables:
  GIT_DEPTH: 0
Unit tests and Sonar Check:
 script:
    - mvn clean verify sonar:sonar
  artifacts:
    reports:
      junit:
        - "*/target/surefire-reports/TEST-*.xml"
  allow_failure: false
  rules:
    - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^FTR-\d+-gl/ && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
      when: always
  tags:
  - sonarqube
  - docker

I got an unexpected side effect (which I actually like) on the merge requests following the criteria above the Jenkins CI Service is not running. Unfortunately I didn’t found any documentation supporting this behaviour and the following page recommend to disable Jenkins CI when having gitlab ci.