GitLab
GitLab is a GIT server and collaboration tool that keeps the source code of the ]project-open[ application.
Basic GIT Operations Cheat Sheet
ToDo: Move these instructions to the developer section
Cheat Sheet from GitLab
Installation / Batch Operations
- Install/clone ]po[ /packages/ folder
- Update entire /packages/ folder:
These instructions first create an ~/packages/all-pull.bash file and then executes the file:
# cd ~/packages/
# find "$(pwd -P)" -maxdepth 1 -mindepth 1 -type d -exec echo "echo {}; cd {}; git pull" \; > all-pull.bash
# bash all-pull.bash > all-pull.log 2>&1 &
- Search for a string in all packages:
# cd ~/packages/
# find . -type f -exec grep -il <string> {} \;
Operations on Individual Packages
- Install/clone a package:
# cd ~/packages
# git clone https://gitlab.project-open.net/project-open/<package>
- Update individual package to origin/master, possibly merging local changes:
# cd ~/packages/<package>; git pull
- Review the changes in the last 5 commits (after a git pull):
# git log --name-status -5
- Reset package content to master branch, discarding all local changes:
# cd ~/packages/<package>
# git fetch --all
# git reset --hard origin/master
- Create a new package:
Create a new package in https://gitlab.project-open.net/ -> "New Project":
- Name: intranet-xxx-yyy
- Project URL: https://gitlab.project-open.net/project-open/
- Project slug: intranet-xxx-yyy
- Visibility: Public, unless it's a customer specific package
Now follow the instructions to push an existing folder:
- cd <existing_folder>
- git init
- git remote add origin https://gitlab.project-open.net/project-open/intranet-taskjuggler.git
- git add .
- git commit -m "Initial commit"
- git push -u origin master
API Cheet Sheat
- List all projects:
We need to get the projects in several pages because of a page limit of 100:
curl --header "Private-Token: xxx" "https://gitlab.project-open.net/api/v4/projects?per_page=100&page=1" | python -m json.tool > projects.json
curl --header "Private-Token: xxx" "https://gitlab.project-open.net/api/v4/projects?per_page=100&page=2" | python -m json.tool >> projects.json
curl --header "Private-Token: xxx" "https://gitlab.project-open.net/api/v4/projects?per_page=100&page=3" | python -m json.tool >> projects.json
curl --header "Private-Token: xxx" "https://gitlab.project-open.net/api/v4/projects?per_page=100&page=4" | python -m json.tool >> projects.json
PostgreSQL Database Cheat Sheet
There are several quirks in the GitLab GUI and API.
A simple way to work around that is to set values directly in the PostgreSQL database:
- Connect to database:
From local gitlab server:
# sudo -u gitlab-psql -i bash -c '/opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production'
Remotely:
psql --host=gitlab --username=gitlab --dbname=gitlabhq_production
- Restart PostgreSQL:
# gitlab-ctl restart postgresql
- List all database tables:
# sudo -u gitlab-psql -i bash -c '/opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production -c "\\d"'
- Make a project publicly visible:
update projects set visibility_level = 20 where id=79;
update projects set visibility_level = 20 where name='intranet-xxx';
Visibility levels are: 0=private, 10=internal, 20=public
Enable Access to GitLab PostgreSQL
- As root login to the PostgreSQL user:
su - gitlab-psql
- In ~/data/postgresql.conf change
listen_address = ''
to
listen_address = '*'
- In ~/data/pg_hba.conf add line
host all all 192.168.0.0/16 md5
- In the PG database (connect locally, see above):
alter user gitlab with password '<secure_password>';
- Open firewall as root:
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload
- Restart PG as root:
gitlab-ctl restart postgresql
Run as root "netstat -nlp | grep 5432". You should see PostgreSQL now listening on a public port.
Then try to connect remotely using the following command:
psql --host=gitlab --username=gitlab --dbname=gitlabhq_production
.. and provide the <secure_password> from above.
Servers