# Some scripts to automate gitlab - to create a `gitlab.cfg` that contains your gitlab token (see `gitlab.cfg.sample`). ```json [telecomnancy] url = https://gitlab.telecomnancy.univ-lorraine.fr private_token = -YOUPRIVATETOKEN- #oauth_token = notimplemented api_version = 4 ``` - to create a `.json` file that contains student informations (`convert-students-list-as-json.py` can generate one from an excel file). The expected format is: ```json [ { "lastname": "Paul", "firstname": "Savate", "email": "paul.savate@telecomnancy.eu", "git_username": "paul.savate", // could be generate from email (update-json-students-list-gitusername.py) "git_uid": 666, // could be retrieved from gitlab (validate-gitlab-users.py) "uid": "savate1u", // could be retrieved from LDAP (update-json-students-list-with-ldap.py) "group": "" }, { "lastname": "John", "firstname": "Snow", "email": "john.snow@telecomnancy.eu", "git_username": "john.snow", "git_uid": 432, "uid": "snow7u", "group": "" } ] ``` ## Python Package Dependencies - openpyxl - python-ldap - python-gitlab - gitpython ## Usage 101 1. `convert-students-list-as-json.py` to create basic .json database from students list (.xslx from intranet) -- some variable have to be updated in the current script 2. `update-json-students-list-with-ldap.py` to retrieve `uid` (unix login) (do not forget to connect via VPN) -- you may need to update the ldap OU to match the right students group -- - `./update-json-students-list-with-ldap.py -s data/2020-2021/1a-fise.json` 3. `update-json-students-list-gitusername.py` to compute gitlab username from email - `./update-json-students-list-gitusername.py -s data/2020-2021/1a-fise.json` 4. `validate-gitlab-users.py` to check that all students have a gitlab account (and their gitlab username id known) - first run to validate `./validate-gitlab-users.py -s data/2020-2021/1a-fise.json` - second run with `-uid true` to update gitlab uid in .json file 5. create a bunch of gitlab projects for each student: - `./create_gitlab_projects.py -s data/2020-2021/1a-fise-top.json taps2k21 lab1 "Lab #1 - My First Problem Solving Experience"` 6. push some code (from a local git repository): - `./push_in_gitlab_projects.py -s data/2020-2021/1a-fise-top.json -b master taps2k21 lab1 ../taps2k21-lab1.git/` 7. assign student to their project: - `./put_student_in_gitlab_projects.py -s data/2020-2021/1a-fise-top.json taps2k21 lab1` ### To manage gitlab project per group of students 1. `convert-groups-list-as-json.py` to generate the .json containing group information / members 2. `validate-gitlab-users-from-groups.py` to check all users in groups exist in gitlab 3. Then you can create a bunch of gitlab projects for your groups and assign students as members: ```bash ./create_gitlab_projects-for-groups.py ppii-2k20 project 'PPII <Projet Pluridisciplinaire d Informatique Intégrative> (2019-2020)' --groups_file ./data/2019-2020/ppii-fise-groups.json ``` 4. `push_in_gitlab_projects-for-groups.py` to push some code (from a local repository) to these projects: ## Additional commands - `clone_all_projects.py` to clone all project (one project per student) - `clone_all_projects-for-groups.py` to clone all project (one project per group of students) - `protect_branch_in_gitlab_projects.py` to protect a branch in all repositories - `create_merge_request.py` to create a merge request on all projects - `remove_gitlab_projects.py` to remove gitlab projects - `retrieve_archive_from_gitlab_projects.py` to retrieve zip file of each git repository - `update_student_in_gitlab_projects.py` to change access right of students (variable to be updated in the script) - `print-collected-ldap-data.py` print data that can be collected from LDAP - `generate-mailmap-for-groups.py` to help generate a mailmap file - `get_pipelines_status.py` to print status of gitlab pipelines - `test-delete-pipelines.py` to delete a pipeline - `./update_topics_of_gitlab_projects.py` to add tags to project (the group who student belongs to will also be tagged) ## Misc 2021 - `./create_gitlab_projects.py -s data/2020-2021/1a-fise-top.json taps2k21 lab3 "Lab #3 - Pyramids"` - `./create_groups_from_xlsx.py -m ./data/2020-2021/liste_2020-2021_groupes_projet_TAPS_2020-10-24.xlsx -s data/2020-2021/1a-fise-top.json -o ./data/2020-2021/1a-fise-taps-groups.json` - `./create_groups_from_xlsx.py -m ./data/2020-2021/liste_2020-2021_groupes_projet_TAPS_2020-11-03.xlsx -s data/2020-2021/1a-fisa.json -o ./data/2020-2021/1a-fisa-taps-groups.json` - `./create_gitlab_projects-for-groups.py taps2k21 project 'TAPS <Techniques and Algorithms for Problem Solving> (2020-2021)' --groups_file ./data/2020-2021/1a-fisa-taps-groups.json` - `./create_gitlab_projects-for-groups.py taps2k21 project 'TAPS <Techniques and Algorithms for Problem Solving> (2020-2021)' --groups_file ./data/2020-2021/1a-fise-taps-groups.json` - `./update_topics_of_gitlab_projects.py -s data/2020-2021/1a-fise-top.json -t taps,2k21,lab2,stringrec taps2k21 lab2`