After setting up GitLab, I wanted to create a project workflow using Labels. However, I did not like the default ones. I set them up a my first Test project, but wanted to replicate the Labels across all future projects. There was a lot of googling and grepping involved, but I found out how to do it.
All of the default labels are created in the file:
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/issues_labels.rb
I saved a backup of the existing issues_labels.rb, then I edited my to follow my desired workflow is basically involved setting a color and default text for each of my new labels as follows:
module Gitlab class IssuesLabels class << self def generate(project) orange = '#D99100' dk_orange = '#D95100' lt_green = '#A8D659' dk_green = '#5CB85C' lt_blue = '#A8DEEE' grey = '#7F8C8D' blue = '#428BCA' lt_orange = '#F0AD4E' lt_red = '#D9534F' labels = [ { title: "Bug", color: orange }, { title: "Bug - KI", color: dk_orange }, { title: "Dev - Design", color: dk_green }, { title: "Dev - Unit Test", color: dk_green }, { title: "Dev - Validation", color: dk_green }, { title: "Dev - Verification", color: dk_green }, { title: "Dev - Backlog", color: lt_green }, { title: "Documentation", color: lt_blue }, { title: "Enhancement", color: lt_blue }, { title: "Evaluated - Dropped", color: grey }, { title: "Evaluated - Duplicated", color: grey }, { title: "New", color: blue }, { title: "Support", color: lt_orange }, { title: "Priority - Critical", color: lt_red }, { title: "Priority - Low", color: lt_blue } ] labels.each do |label| project.labels.create(label) end end end end end
Afterwards a restart of GitLab was required
$ gitlab-ctl restart
Now when I create a new project, I will get the default Labels I use in my workflow.
– Update 5/31/16 – After running both a “gitlab-crl upgrade” as well as the ‘yum update all” my custom settings still exist.
– Update 10/2/16 – a cut and paste from above may cause GitLab (specifically unicorn) to not start. Here my current issues_labels.rb in case you need the raw file.