Sometimes you might need to do some task in GitLab which would be tedious if you'd have to do it via the Browser.
There is also anwhich you could maybe use!
You can connect to the GitLab internal Rails with executing
gitlab-rails console. It might be slow at times, especially if you use a lot of
Tab for complex structures, so be aware of this.
The following code listings are expected to be entered inside the
p = Project.find_by_id(1) labels_to_remove = [3, 4, 1, 84, 86] # Scheduled, Active, This Week, One Week, Two Weeks # for every issue p.issues.each do |issue| # we edit only closed issues if issue.closed? # remove our unwanted labels issue.label_ids -= labels_to_remove if issue.valid? # and save the issue issue.save end end end
Hint: The Issue ID we know is to be found as
iid in GitLab.
First we need to find our project. In our case, this is the
makandra-ops/puppet project, which as it happens, was the first project in this GitLab:
p = Project.first
Now we have a filter and we're able to see only issues that concern us. You can take a look in all supported methods of the issue Object without having to wait for tab completion by using this line:
i = p.issues.find_by_iid(4042) puts i.public_methods.sort
Maybe you want to save this list to be able to search for stuff in it.
Here we want to remove labels from issues they no longer need. These are the Labels
Two Weeks with the respective
label ids 3, 4, 1, 84, 86 which leads to the above code snipped.