When you install the GitLab extension, an additional filebrowser tab will be added to the left area of JupyterLab. This filebrowser allows you to select GitLab groups and users, browse their repositories, and open the files in those repositories. If those files are notebooks, you can run them just as you would any other notebook. You can also attach a kernel to text files and run those. Basically, you should be able to open any file in a repository that JupyterLab can handle.
This is not an extension that provides full GitLab access, such as saving files, making commits, forking repositories, etc. If you want to use Git from JupyterLab, you should look at the jupyterlab-git extension.
Getting your credentials from GitLab.
You need to create a personal access token to authenticate yourself to GitLab.You can get an access token by following these steps:
- Go to https://gitlab.com/profile/personal_access_tokens or from GitLab, go to your "Settings" > "Access Tokens".
- Under "Name", enter a short description, to identify the purpose of this token. I recommend something like: jupyterlab-gitlab.
- Under "Scopes", check the "api" scope.
- Click "Create personal access token". You will see your new personal access token (a 21 characters string).
- Click on the copy to clipboard icon and and paste it locally in a text file for now.
This is the only time you'll see this token in GitLab. If you lose it, you'll need to create another one.
Remember that this token is effectively a password for your GitLab account. Do not share it online or check the token into version control, as people can use it to access all of your data on GitLab.
Configure the server extension.
You should now add the credentials you got from GitLab to your notebook configuration file (if you do not have that file, you need to create it).
To create a jupyter_notebook_config.py file in the .jupyter directory use the following command:
jupyter notebook --generate-config
Then, add the following line to it:
c.GitLabConfig.access_token = "< YOUR_ACCESS_TOKEN >"
where < YOUR_ACCESS_TOKEN > is the string value you obtained above.
Customizing the extension.
You can set the plugin to start showing a particular repository at launch time. Open the "Advanced Settings" editor in the JupyterLab Settings menu, and under the GitLab settings add:
where owner is the GitLab user or group, and repository is the name of the repository you want to open.