Trouble Shooting GitLabCI

Trouble Shooting GitLabCI

I saw a post recently on LinkedIn by Jim Kring. He had some issues with a build hanging unexpectedly. They were running Jenkins under a system account and therefore it was really hard to see what was going on to be able to troubleshoot it. Jim then linked to a blogpost where he discussed how to run Jenkins under a user account so that you could see what is going on.

I had some similar problems previously using GitLab and had come up with a similar solution. I have been meaning to write about it, but hadn’t gotten around to it yet. Now is a good time, especially since I am about to start a new project and set up another new runner.

The problems with running under a system account

There are really 2 problems with running as a system account.

  1. As Jim outlined, you can’t see what is going on. Particularly in LabVIEW if something is hanging up (like perhaps some kind of LabVIEW dialog) you can’t see it.
  2. I’ve encountered problems with both file permissions and environment variables. When you run gitlab-runner under a system account, those are different and that can cause problems.

Accessing the Build Machine

The first thing you need is a way to access the build machine. I like Windows Remote Desktop (RDP). RDP is quick and easy and there are RDP clients for Linux, so it works well for me. Do keep in mind that RDP is not secure and you should never use it over the internet, but on a local network behind a firewall you should be fine.

Installing GitLab Runner

To install GitLab runner follow the instructions here. Complete Steps 1 through 5 and then STOP. We’re not going to run it as a service at all. We are going to run it on logon.

Using Git Bash

I like to use Git Bash as opposed to PowerShell. There are some other steps you have to take to set that up. Once you have that set up, there is one more step and that is to create the following batch file with the following line in it.

"C:\Program Files\Git\bin\sh.exe" --login -i -c "cd /c/Gitlab-Runner && ./gitlab-runner.exe run"

Running this batch file will open a console window as seen below. Once a job starts, then you’ll see all the windows that it opens. You’ll see the LabVIEW splash screen and any VIs it opens. So if it hangs on some dialog, you will know about it.

Running On Startup

The next step would be to set gitlab-runner to automatically run on startup. For that I use Windows Task Scheduler to run the batch file to run on logon. If you want, you set the user to autologon and then whenever the computer boots up, gitlab-runner will be running. If for some reason, the machine reboots, then gitlab-runner will startup again.

Once you’ve done that you can use netplwiz to setup autologon.

Want to learn more?

Check out my Thinking Incrementally Workshop at GDevCon N.A. We will cover this and a bunch of other related topics.