TOOL/CI 2019. 12. 20. 16:11

GitLab-Runner

Install - GitLab-Runner on Docker for Windows

Docker for Windows 로는 실패하였지만 "Windows에 GitLab-Runner를 설치 할 수 있다."

(혹시 GitLab 설치법(Docker이용)은 이곳을 참조 => https://forgiveall.tistory.com/552)

Install - GitLab-Runner on Windows

1. Environment - 환경

  • Windows10 Pro
  • GitLab-CE 12.2.3 (13598699b0a)
  • GitLab-Runner 12.2.0 <- 이번에 설치해보자!

2. Install - 설치

1. 폴더만들기
mkdir c:\GitLab-Runner
2. 파일다운
  • c:/GitLab-Runnergitlab-runner-windows-amd64.exe를 다운로드
3. Register
3-1. GitLab-Runner를 service로 등록한다.
cd C:\GitLab-Runner
.\gitlab-runner-windows-amd64.exe register
3-2. GitLab의 Web주소를 적는다.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://localhost/
3-3. GitLab에 생성한 Project의 Runners Token을 적는다.
  • 당신의 Project > [Settings] > [CI/CD] 에서 Runners를 [Expands]하면 gitlab-ci token을 얻을 수 있다.

    Please enter the gitlab-ci token for this runner:
    {PUT_YOUR_TOKEN_FROM_ON_YOUR_PROJECT_SETTING_PAGE}
  • 해당 Tag의 설명을 적어 넣는다. (역할이랄지..)

      Please enter the gitlab-ci description for this runner:
3-4. .gitlab-ci.yml에 명시하여 사용할 runner의 tag 이름을 정하여 적는다.
Please enter the gitlab-ci tags for this runner (comma separated):
myproject-ci-tag

Registering runner... succeeded runner=_iM5B6ws

3-5. 위의 tag를 .gitlab-ci.yml에서 사용할 때 설계한 script를 실행할 실행자를 선택한다. (필자는 docker 또는 shell을 활용하여 CI를 구축하였다.)
Please enter the executor: docker-windows, parallels, docker+machine, custom, docker, docker-ssh, shell, ssh, virtualbox, docker-ssh+machine, kubernetes:
docker

Docker 설정시 image를 설정하지 않을 경우에 사용될 기본 Image를 적는다. ('alpine'이 적당할 것이다.)

Please enter the default Docker image (e.g. ruby:2.6):
alpine
4. 실행
./gitlab-runner.exe install
./gitlab-runner.exe start
  • gitlab-runner Windows Service가 생성되고 실행된다.

3. Project에 .gitlab-ci.yml를 작성

1. 특정 Project의 root 디렉토리에 CI Script 생성하여 git push를 해본다.
  • .gitlab-ci.yml

      deploy_to_develop:
          stage: deploy
          tags: # GitLab-Runner를 생성할 때 지은 Tag명을 적는다.
              - jelly-ci-tag
          only: # 정확히 어떤 Branch에서만 작동할지 명시한다.
              - develop 
              - ci-test
          except: # 작동하지 않을 Branch를 명시한다. (only가 있다면 사실 필요없다.)
              - master 
          before_script:
              - echo 'Start !!'
          script: # 당신의 멋진 스크립트를 기술해 보자!!
              - echo 'deploy to develop server'
              - 'net use o: \\서버IP\소스코드_경로 서버접속PW /user:서버접속ID'
              - 'xcopy . o:\ /h /k /y /e /r /d'
          after_script:
              - echo 'Done !!'

Reference - 참조

Install
Issue - Gitlab runner connection refused, unable to access ... 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@localhost/mygroup/myproject.git/': Failed to connect to localhost port 80: Connection refused
.gitlab-ci.yml