Wildcard branches in YAML

Is it possible to have wildcards in the branch name in the YAML CI file?

My dev would like the master to be the Cutting edge branch that is automatically build, pushed and deployed to the staging environment. This is easy enough.

For the stable, production, environment he works with branches. When a new version is ready to ship out, he creates a “stable-” branch, builds this with a separate CI file in this branch and then continues work on the master, until a new stable is ready.

I’d like to automate this process
I tried setting the “only” in the YAML file like this, but neither option seems to work
only:
- stable-*
only:
- “stable-*”

Can this be done?

@Fraeco, you should use the regex notation for wildcard notations. If I understand your question correctly this is what you want:

jobname:
  only:
    - /^stable-.*$/
  except:
    - master
  script:
    - do stuff

Apart from that I would advise to have your dev look into Gitlflow. We changed to this concept a while back and its really working out. Even in an OTAP (saw you are dutch speaking :wink: environment.

I have 1 gitlab-ci.yml file for all stages of the Gitflow including the creation of the release-* branch and different tags as as CI job. And as I described in the other post we also work with Rancher. Feel free to contact me.

2 Likes

Thanks @stefanvangastel it works for me