What is the cleanest way to create a project in a self hosted gitlab with predefined (dynamically generated) files?
Concretely, I want to create a git repo on gitlab that upon creation contains all the files of a basic iOS project already. I just have to clone it and just start developing, instead of creating the project locally and then push it up to Gitlab.
Anyone?
I was looking into the gitlab-shell and the creation hook in gitlab-project: https://github.com/gitlabhq/gitlab-shell/blob/master/lib/gitlab_projects.rb
Am I about to embark on a world of pain following this method? Is there something already out there that makes it easy to hook up at the application level?
yml file. CI/CD templates incorporate your favorite programming language or framework into this YAML file. Instead of building pipelines from scratch, CI/CD templates simplify the process by having parameters already built-in. You can choose one of these templates when you create a gitlab-ci. yml file in the UI.
For GitLab CE (or EE too, if you need more features than the standard templates provide) I propose using this set of tools:
configure system hooks in GitLab to make it fire a POST
request on project_create
events,
set up adnanh/webhook as a server that will receive these POST
requests and then run egnyte/gitlabform app to configure the new project,
create configuration for gitlabform with any files you need. Example:
gitlab:
url: https://gitlab.yourcompany.com
# You can also set in your environment GITLAB_TOKEN
# this can be both private token OR OAuth2 access token
token: "<private token of an admin user>"
api_version: 4
group_settings:
# this assumes that you create your new iOS projects in a "ios" group in GitLab
ios:
files:
"README.md":
# this will prevent resetting the file to below contents if it has already been customized
overwrite: false
# this will prevent the commit that applies this file change triggering CI build
skip_ci: true
branches:
- develop
content: |
This is a default project README. Please replace it with a proper one!
"other-file":
branches:
- develop
# You can provide file contents with external file too. Both absolute and relative paths are supported.
# Relative paths are interpreted as relative to `config.yml` file location.
file: some-file.txt
See https://github.com/egnyte/gitlabform for more info about the features, more examples and a full config syntax description.
Disclosure: I am the original author of egnyte/gitlabform app and I have contributed to adnanh/webhook and therefore I like them both. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With