NMT CSE Wiki

Dept. of Computer Science & Engineering

User Tools

Site Tools


commons:tobor-runner

Using GitLab to Deploy/Build Your Code


OUT OF DATE some content on this page is out of date as of 10-09-2018

This page will be fleshed out more in the future, but provides basic instructions on how to use the CI environment we've set up.

Basic Setup

The following setup will run your code as if you were on a lab machine. This is really useful for projects that require your code to build on lab machines, or if you work on an OSX/Windows computer and want to view the output of your file whenever you push without needing to use SSH.

Assuming you already have a GitLab repository for your project, create and commit a file in your GitLab repo called .gitlab-ci.yml at the top level that looks similar to this:

stages:
  - example
  - anotherstage
  - onemore

example:
  tags:
    - labs
    - shell
  stage: example
  script:
    -echo "Hello World!"
 
#defintions for all other stages would be below

The important thing in the above block is that you have at least one stage, and that the tags section in the definition of that stage includes both the labs and shell tags. These tags will force the runner for your CI script to work as if it were running on a lab machine. Entries made in the script section will be executed in a shell environment, and the output of these commands is visible on GitLab.

For Web Programmming

Complete the basic setup work above. Now, on Takyon, from your apollo account edit the file ~/.ssh/authorized_keys using your preferred editor. Add the following block of text as a single line.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5WkIjf9avHL3LeFYsjnRe+v2ZxFGqF42vY6ZtSQ+99kRjVjYxr9dWCTmUEXog6tsHBz3ZRWQZiqMayYgj7y5ju/fcnehB2LiubK6qXNAI+YqNqIoYoKe/rMoqRVhGqj3Ln9bZSZS6AlyanomFeGJ0acx2fmU8Y8GCRlk6ae5E8eiw6D7Wv+lHysKn++P10SOGdeBxM4lgHw5hl7GpRHCwvCNZELv3I9++6+puKEnGM1itcX806ubsT8Omz+OIUOaY6O2wA0LxqfxFMu5SIcW/5phIoNc7lKidsP8HUVh7wlBzLjePLDG8uKIWYvymo9cl7lDMwKwschAMU6pY0sTv gitlab-runner@tobor.cs.nmt.edu

This is the public key for the tobor GitLab runner, i.e., it authorizes the GitLab runner to sign into your Takyon account. Please keep in mind that this means that anyone who has also done this will be able to execute commands as your user. Be careful with this.

With the public key file added, a minimal CI runner that copies the contents of your repository to your userhome on Takyon, but only whenever master updates, would look like this:

stages:
  - deploy

deploy:
  tags:
    - labs
    - shell
  stage: deploy
  only:
    - master
  script:
    -scp . apollo.X@takyon.cs.nmt.edu:~/ #Replace X with your apollo number
commons/tobor-runner.txt · Last modified: 2018/10/09 14:33 by tristan