Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Setting Up SDC with GitLab Repositories

The following sections provide instructions for SDC users on setting up GitLab repositories for
committing and sharing their code and any other documents.


GitLab provides an organizational structure of users and repositories managed respectively via
“groups” and “projects” to promote collaboration among teams of SDC users. Groups contain
members with different access levels to their project repositories based on the assigned roles:

GitLab Features:

  • Share code with specific team members, your entire team, or different research teams that are also using the SDC.

  • Simplified collaboration with shared read/write access.

  • Manage multiple repositories that are organized and structured in a logical manner.

  • Version control and source code management including:

    • File locking to help prevent conflicts

    • Users can work from their local copy of the code

    • Users can branch code to make changes and then quickly merge it after approval

🚪 Log In to GitLab

  1. Within your SDC workstation, open a web browser, then navigate to https://gitlab.prod.sdc.dot.gov. This is the URL to the SDC’s internal GitLab.

  2. In the Sign in page, the LDAP login option is selected by default. Enter your SDC credentials as the LDAP username and password, then click Sign in (in the LDAP Username field, do not enter the “@securedatacommons.com” portion of your SDC username).

  3. The Welcome to GitLab web page is displayed.

(info) Create a Group

  1. In the Welcome to GitLab web page, select Create a group.

  2. The New group form appears. Enter the name for the new group.

  3. Select the Private option under Visibility level to only allow members in the group to see the group and its projects.

  4. Select Create group.

  5. A success message appears indicating that the group was created. You are now ready to add members to the group.

(plus) Add Group Members

Users assigned with the “Developer” or “Maintainer” role can add other GitLab members in the
SDC to their groups.

NOTE: SDC users are listed as a GitLab member in the Members panel only after they have
logged into GitLab. If you do not see your SDC colleague listed, please ask them to log in to
GitLab.

  1. In the newly created project web page, click Members from the left navigation menu.

  2. In the “Search for members” text box, start entering the name of the SDC user you want to add; then select the member’s name from the autocomplete list.

  3. Select a role from the next drop-down menu. You can select the “Read more” link to view a comprehensive list of the different available permission levels and their access rights. A summary of the roles’ access types is also shown in Table 1 at the beginning of this chapter.

  4. Select Add to group.

(lightbulb) Create a Project

  1. Select the GitLab icon on the upper left to return to the home page.

  2. Select Create a project.

  3. The New project form appears. Enter a name for the project.

  4. Select the Private option under Visibility level, so that the project is only visible to users who are granted explicit access to the project.

  5. Select the Initialize repository with README checkbox to automatically generate a readme file that contains the project’s repository details.

  6. Select Create project.

7. A success message appears indicating that the project repository was created. You are
now ready to add members to the project.

(plus) Add Members or Groups to a Project

  1. Select the GitLab icon on the upper left to return to the home page.

  2. A list of your projects appears. Select the name of the project you want to add members
    /groups to.

  3. Click on Settings and then Members from the left navigation menu.

  4. You can add individual users or entire groups to the project.

    1. Select the Invite member tab to add members individually to the project.

      1. Start entering the project member’s name or email address into GitLab
        member or Email address to select from the autocomplete list.

      2. Select a role for the project member from the drop-down menu under Choose a role permission.

      3. Click Add to project.

    2. Select the Invite group tab to add an entire group to the project.

      1. Start entering the group’s name into Select a group to invite to select from
        the autocomplete list.

      2. Select a role to apply for the group from the drop-down menu under Max
        access level.

      3. Select Invite to grant the group access to the project repository.

🔑 Generate SSH Key

To set up git integration, you need to have an SSH key on your SDC workstation. This key
authenticates your identification to GitLab so that you can push commits to the project
repository.

  1. To store your authentication credentials for git, use a hidden folder called “.ssh.” First,
    check to see if the folder exists with ls –a.

    ls –a

    If not, create it using the command mkdir .ssh:

    mkdir .ssh
  2. Confirm this works by entering ls –a to see all objects in the current directory. You should see the .ssh listed:

    ls –a
  3. Generate a new key to store in this location by typing the following command and then hitting the Enter key:

  4. It will output the following message: “Generating public/private rsa key pair.”

  5. It will ask you where to save the file and to enter a passphrase with the following three
    prompts. Hit the Enter key each time (no need to enter anything else) to accept the
    defaults.
    • “Enter file in which to save the key:”
    • “Enter passphrase (empty for no passphrase):”
    • “Enter same passphrase again:”

  6. After the following confirmation messages, the new SSH key is now stored in the .ssh
    folder.
    • “Your identification has been saved in /c/Users/SDCusername/.ssh/id_rsa.”
    • “Your public key has been saved in /c/Users/SDCusername/.ssh/id_rsa.pub.” The default key file name is id_rsa and is saved under the .ssh folder (e.g.,
    C:/Users/[SDCusername]/.ssh/ in Windows; $HOME/.ssh/id_rsa in Linux)

  7. You now need to provide the public part of this key to GitLab by copying the “.pub” part
    of the key. Here are the different options for copying the public SSH key. Option 1:
    On Windows, open the id_rsa.pub file (under the C:/Users/[SDCusername]/.ssh folder) in
    a text editor (Notepad) and copy the entire key by using Select All then Copy. Be careful
    not to accidentally change anything!
    Option 2:
    Copy your public SSH key to the clipboard by using one of the commands below
    depending on your Operating System: Git Bash on Windows:

    cat ~/.ssh/id_rsa.pub | clip

    WSL/GNU/Linux (requires the xclip package):

    xclip -sel clip < ~/.ssh/id_rsa.pub

    If using Jupyter, use the head command. Right-click on the output and click copy:

    head ~/.ssh/id_rsa.pub

  8. From the GitLab home page, add your public SSH key to your GitLab account:
    a. In the upper-right corner, click on your avatar image and then click Settings.
    b. From the left navigation menu, click SSH Keys.
    c. In the Key field, paste your public SSH key.
    d. The Title field will be automatically populated with SDCusername@securedatacommons.com.
    e. Click the Add key button.

  9. To test whether your SSH key was added correctly, run the following command in your
    terminal:

    ssh -T git@scm. internal.sdc.dot.gov
  10. The first time you connect to GitLab via SSH, you will be asked to verify the authenticity
    of the GitLab host you are connecting to. Type “yes” to add the SDC internal GitLab to
    the list of trusted hosts.

  11. You should see the “Welcome to GitLab, @username!” message.

NOTE: Once added to the list of known hosts, you will not be asked to validate the
authenticity of SDC internal GitLab’s host again. Run the above command once more,
and you should only receive a “Welcome to GitLab, @username!” message.

If the Welcome message does not appear, run SSH in verbose mode by replacing -T with -vvvT to debug the error:

ssh -vvvT git@scm. internal.sdc.dot.gov
  • No labels