github.com/secure-build/gitlab-runner@v12.5.0+incompatible/docs/install/freebsd.md (about)

     1  ---
     2  last_updated: 2019-07-15
     3  ---
     4  
     5  # Install GitLab Runner on FreeBSD
     6  
     7  NOTE: **Note:**
     8  The FreeBSD version is also available as a [bleeding edge](bleeding-edge.md)
     9  release. Make sure that you read the [FAQ](../faq/README.md) section which
    10  describes some of the most common problems with GitLab Runner.
    11  
    12  CAUTION: **Important:**
    13  If you are using or upgrading from a version prior to GitLab Runner 10, read how
    14  to [upgrade to the new version](#upgrading-to-gitlab-runner-10). If you want
    15  to install a version prior to GitLab Runner 10, [visit the old docs](old.md).
    16  
    17  ## Installing GitLab Runner
    18  
    19  Here are the steps to install and configure GitLab Runner under FreeBSD:
    20  
    21  1. Create the `gitlab-runner` user and group:
    22  
    23     ```sh
    24     sudo pw group add -n gitlab-runner
    25     sudo pw user add -n gitlab-runner -g gitlab-runner -s /usr/local/bin/bash
    26     sudo mkdir /home/gitlab-runner
    27     sudo chown gitlab-runner:gitlab-runner /home/gitlab-runner
    28     ```
    29  
    30  1. Download the binary for your system:
    31  
    32     ```sh
    33     # For amd64
    34     sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
    35  
    36     # For i386
    37     sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-386
    38     ```
    39  
    40     You can download a binary for every available version as described in
    41     [Bleeding Edge - download any other tagged release](bleeding-edge.md#download-any-other-tagged-release).
    42  
    43  1. Give it permissions to execute:
    44  
    45     ```sh
    46     sudo chmod +x /usr/local/bin/gitlab-runner
    47     ```
    48  
    49  1. Create an empty log file with correct permissions:
    50  
    51     ```sh
    52     sudo touch /var/log/gitlab_runner.log && sudo chown gitlab-runner:gitlab-runner /var/log/gitlab_runner.log
    53     ```
    54  
    55  1. Create the `rc.d` directory in case it doesn't exist:
    56  
    57     ```sh
    58     mkdir -p /usr/local/etc/rc.d
    59     ```
    60  
    61  1. Create the `rc.d` script:
    62  
    63     ```sh
    64     sudo bash -c 'cat > /usr/local/etc/rc.d/gitlab_runner' << "EOF"
    65     #!/bin/sh
    66     # PROVIDE: gitlab_runner
    67     # REQUIRE: DAEMON NETWORKING
    68     # BEFORE:
    69     # KEYWORD:
    70  
    71     . /etc/rc.subr
    72  
    73     name="gitlab_runner"
    74     rcvar="gitlab_runner_enable"
    75  
    76     user="gitlab-runner"
    77     user_home="/home/gitlab-runner"
    78     command="/usr/local/bin/gitlab-runner"
    79     command_args="run"
    80     pidfile="/var/run/${name}.pid"
    81  
    82     start_cmd="gitlab_runner_start"
    83  
    84     gitlab_runner_start()
    85     {
    86         export USER=${user}
    87         export HOME=${user_home}
    88         if checkyesno ${rcvar}; then
    89             cd ${user_home}
    90             /usr/sbin/daemon -u ${user} -p ${pidfile} ${command} ${command_args} > /var/log/gitlab_runner.log 2>&1
    91         fi
    92     }
    93  
    94     load_rc_config $name
    95     run_rc_command $1
    96     EOF
    97     ```
    98  
    99  1. Make it executable:
   100  
   101     ```sh
   102     sudo chmod +x /usr/local/etc/rc.d/gitlab_runner
   103     ```
   104  
   105  1. [Register the Runner](../register/index.md)
   106  1. Enable the `gitlab-runner` service and start it:
   107  
   108     ```sh
   109     sudo sysrc -f /etc/rc.conf "gitlab_runner_enable=YES"
   110     sudo service gitlab_runner start
   111     ```
   112  
   113     If you don't want to enable the `gitlab-runner` service to start after a
   114     reboot, use:
   115  
   116     ```sh
   117     sudo service gitlab_runner onestart
   118     ```
   119  
   120  ## Upgrading to GitLab Runner 10
   121  
   122  To upgrade GitLab Runner from a version prior to 10.0:
   123  
   124  1. Stop the Runner:
   125  
   126     ```sh
   127     sudo service gitlab_runner stop
   128     ```
   129  
   130  1. Optionally, preserve the previous version of the Runner just in case:
   131  
   132     ```sh
   133     sudo mv /usr/local/bin/gitlab-ci-multi-runner{,.$(/usr/local/bin/gitlab-ci-multi-runner --version| grep Version | cut -d ':' -f 2 | sed 's/ //g')}
   134     ```
   135  
   136  1. Download the new Runner and make it executable:
   137  
   138     ```sh
   139     # For amd64
   140     sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
   141  
   142     # For i386
   143     sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-386
   144  
   145     sudo chmod +x /usr/local/bin/gitlab-runner
   146     ```
   147  
   148  1. Edit `/usr/local/etc/rc.d/gitlab_runner` and change:
   149  
   150     ```
   151     command="/usr/local/bin/gitlab-ci-multi-runner run"
   152     ```
   153  
   154     to:
   155  
   156     ```
   157     command="/usr/local/bin/gitlab-runner run"
   158     ```
   159  
   160  1. Start the Runner:
   161  
   162     ```sh
   163     sudo service gitlab_runner start
   164     ```
   165  
   166  1. After you confirm all is working correctly, you can remove the old binary:
   167  
   168     ```sh
   169     sudo rm /usr/local/bin/gitlab-ci-multi-runner.*
   170     ```