Move to CE some EE pipelines-related code that belongs to CE
What does this MR do?
This MR upports some code from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2986 that belongs to CE, to minimize conflicts.
What are the relevant issue numbers?
Closes gitlab-org/gitlab-ee#3616
Edited by Grzegorz Bizon