Gitlab에서 CI 데비안편

18003 단어 데비안GitLab

설치



다음 명령으로 deian에 설치하십시오.
지정한 shellsudo가 사용 중이며 sudo 권한이 필요합니다.
$ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5243    0  5243    0     0   7930      0 --:--:-- --:--:-- --:--:--  9873
Detected operating system as debian/7.
Checking for curl...
Detected curl...
Running apt-get update... done.
Installing debian-archive-keyring which is needed for installing 
apt-transport-https on many Debian systems.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/runner_gitlab-ci-multi-runner.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.

버전 지정! ? 1
# cat > /etc/apt/preferences.d/pin-gitlab-runner.pref <<EOF
> Explanation: Prefer GitLab provided packages over the Debian native ones
> Package: gitlab-ci-multi-runner
> Pin: origin packages.gitlab.com
> Pin-Priority: 1001
> EOF

드디어 gitlab-ci-multi-runner 설치
# apt-get install gitlab-ci-multi-runner
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  adduser git git-man less libbsd0 libclass-isa-perl libedit2 liberror-perl libexpat1 libgdbm3 libpopt0 libswitch-perl
  libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-blacklist openssh-blacklist-extra
  openssh-client patch perl perl-modules rsync xauth
Suggested packages:
  gettext-base git-daemon-run git-daemon-sysvinit git-doc git-el git-arch git-cvs git-svn git-email git-gui gitk
  gitweb docker-engine ssh-askpass libpam-ssh keychain monkeysphere ed diffutils-doc perl-doc
  libterm-readline-gnu-perl libterm-readline-perl-perl make libpod-plainer-perl openssh-server
Recommended packages:
  ssh-client
The following NEW packages will be installed:
  adduser git git-man gitlab-ci-multi-runner less libbsd0 libclass-isa-perl libedit2 liberror-perl libexpat1 libgdbm3
  libpopt0 libswitch-perl libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-blacklist
  openssh-blacklist-extra openssh-client patch perl perl-modules rsync xauth
0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.4 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue [Y/n]? ^Ctakara@debian-runner:~$ apt-get install -y gitlab-ci-multi-runner
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
takara@debian-runner:~$ apt-get -y install  gitlab-ci-multi-runner
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
takara@debian-runner:~$ sudo apt-get -y install  gitlab-ci-multi-runner
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  adduser git git-man less libbsd0 libclass-isa-perl libedit2 liberror-perl libexpat1 libgdbm3 libpopt0 libswitch-perl
  libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-blacklist openssh-blacklist-extra
  openssh-client patch perl perl-modules rsync xauth
Suggested packages:
  gettext-base git-daemon-run git-daemon-sysvinit git-doc git-el git-arch git-cvs git-svn git-email git-gui gitk
  gitweb docker-engine ssh-askpass libpam-ssh keychain monkeysphere ed diffutils-doc perl-doc
  libterm-readline-gnu-perl libterm-readline-perl-perl make libpod-plainer-perl openssh-server
Recommended packages:
  ssh-client
The following NEW packages will be installed:
  adduser git git-man gitlab-ci-multi-runner less libbsd0 libclass-isa-perl libedit2 liberror-perl libexpat1 libgdbm3
  libpopt0 libswitch-perl libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-blacklist
  openssh-blacklist-extra openssh-client patch perl perl-modules rsync xauth
0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.4 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Get:1 http://security.debian.org/ wheezy/updates/main libexpat1 amd64 2.1.0-1+deb7u4 [139 kB]
Get:2 http://security.debian.org/ wheezy/updates/main perl-modules all 5.14.2-21+deb7u4 [3442 kB]
Get:3 http://httpredir.debian.org/debian/ wheezy/main libgdbm3 amd64 1.8.3-11 [46.9 kB]
Get:4 http://httpredir.debian.org/debian/ wheezy/main libpopt0 amd64 1.16-7 [56.4 kB]       
Get:5 http://httpredir.debian.org/debian/ wheezy/main libbsd0 amd64 0.4.2-1 [59.3 kB]        
Get:6 http://httpredir.debian.org/debian/ wheezy/main libedit2 amd64 2.11-20080614-5 [72.9 kB]
Get:7 http://httpredir.debian.org/debian/ wheezy/main libxau6 amd64 1:1.0.7-1 [18.8 kB]       
Get:8 http://security.debian.org/ wheezy/updates/main perl amd64 5.14.2-21+deb7u4 [4422 kB] 
Get:9 http://httpredir.debian.org/debian/ wheezy/main libxdmcp6 amd64 1:1.1.1-1 [26.3 kB]
Get:10 https://packages.gitlab.com/runner/gitlab-ci-multi-runner/debian/ wheezy/main gitlab-ci-multi-runner amd64 1.5.3 [22.4 MB]
Get:11 http://httpredir.debian.org/debian/ wheezy/main libxcb1 amd64 1.8.1-2+deb7u1 [50.2 kB]   
Get:12 http://httpredir.debian.org/debian/ wheezy/main libx11-data all 2:1.5.0-1+deb7u2 [194 kB]                       
Get:13 http://httpredir.debian.org/debian/ wheezy/main libx11-6 amd64 2:1.5.0-1+deb7u2 [901 kB]                        
Get:14 http://security.debian.org/ wheezy/updates/main openssh-client amd64 1:6.0p1-4+deb7u6 [1027 kB]                 
Get:15 http://httpredir.debian.org/debian/ wheezy/main libxext6 amd64 2:1.3.1-2+deb7u1 [54.8 kB]                       
Get:16 http://httpredir.debian.org/debian/ wheezy/main libxmuu1 amd64 2:1.1.1-1 [23.6 kB]                  
Get:17 http://httpredir.debian.org/debian/ wheezy/main openssh-blacklist all 0.4.1+nmu1 [1835 kB]
Get:18 http://httpredir.debian.org/debian/ wheezy/main openssh-blacklist-extra all 0.4.1+nmu1 [1835 kB]             
Get:19 http://httpredir.debian.org/debian/ wheezy/main adduser all 3.113+nmu3 [264 kB]                                 
Get:20 http://httpredir.debian.org/debian/ wheezy/main less amd64 444-4 [135 kB]                        
Get:21 http://httpredir.debian.org/debian/ wheezy/main libclass-isa-perl all 0.36-3 [12.3 kB]         
Get:22 http://httpredir.debian.org/debian/ wheezy/main libswitch-perl all 2.16-2 [21.0 kB]                         
Get:23 http://httpredir.debian.org/debian/ wheezy/main patch amd64 2.6.1-3 [121 kB]                               
Get:24 http://httpredir.debian.org/debian/ wheezy/main liberror-perl all 0.17-1 [23.6 kB]                              
Get:25 http://httpredir.debian.org/debian/ wheezy/main git-man all 1:1.7.10.4-1+wheezy3 [1075 kB]                      
Get:26 http://httpredir.debian.org/debian/ wheezy/main git amd64 1:1.7.10.4-1+wheezy3 [6688 kB]                        
Get:27 http://httpredir.debian.org/debian/ wheezy/main rsync amd64 3.0.9-4 [369 kB]                                    
Get:28 http://httpredir.debian.org/debian/ wheezy/main xauth amd64 1:1.0.7-1 [37.2 kB]                                 
Fetched 45.4 MB in 10s (4441 kB/s)                                                                                     
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libgdbm3:amd64.
(Reading database ... 23925 files and directories currently installed.)
Unpacking libgdbm3:amd64 (from .../libgdbm3_1.8.3-11_amd64.deb) ...
Selecting previously unselected package libpopt0:amd64.
Unpacking libpopt0:amd64 (from .../libpopt0_1.16-7_amd64.deb) ...
Selecting previously unselected package libbsd0:amd64.
Unpacking libbsd0:amd64 (from .../libbsd0_0.4.2-1_amd64.deb) ...
Selecting previously unselected package libedit2:amd64.
Unpacking libedit2:amd64 (from .../libedit2_2.11-20080614-5_amd64.deb) ...
Selecting previously unselected package libexpat1:amd64.
Unpacking libexpat1:amd64 (from .../libexpat1_2.1.0-1+deb7u4_amd64.deb) ...
Selecting previously unselected package libxau6:amd64.
Unpacking libxau6:amd64 (from .../libxau6_1%3a1.0.7-1_amd64.deb) ...
Selecting previously unselected package libxdmcp6:amd64.
Unpacking libxdmcp6:amd64 (from .../libxdmcp6_1%3a1.1.1-1_amd64.deb) ...
Selecting previously unselected package libxcb1:amd64.
Unpacking libxcb1:amd64 (from .../libxcb1_1.8.1-2+deb7u1_amd64.deb) ...
Selecting previously unselected package libx11-data.
Unpacking libx11-data (from .../libx11-data_2%3a1.5.0-1+deb7u2_all.deb) ...
Selecting previously unselected package libx11-6:amd64.
Unpacking libx11-6:amd64 (from .../libx11-6_2%3a1.5.0-1+deb7u2_amd64.deb) ...
Selecting previously unselected package libxext6:amd64.
Unpacking libxext6:amd64 (from .../libxext6_2%3a1.3.1-2+deb7u1_amd64.deb) ...
Selecting previously unselected package libxmuu1:amd64.
Unpacking libxmuu1:amd64 (from .../libxmuu1_2%3a1.1.1-1_amd64.deb) ...
Selecting previously unselected package openssh-blacklist.
Unpacking openssh-blacklist (from .../openssh-blacklist_0.4.1+nmu1_all.deb) ...
Selecting previously unselected package openssh-blacklist-extra.
Unpacking openssh-blacklist-extra (from .../openssh-blacklist-extra_0.4.1+nmu1_all.deb) ...
Selecting previously unselected package adduser.
Unpacking adduser (from .../adduser_3.113+nmu3_all.deb) ...
Selecting previously unselected package less.
Unpacking less (from .../archives/less_444-4_amd64.deb) ...
Selecting previously unselected package libclass-isa-perl.
Unpacking libclass-isa-perl (from .../libclass-isa-perl_0.36-3_all.deb) ...
Selecting previously unselected package perl-modules.
Unpacking perl-modules (from .../perl-modules_5.14.2-21+deb7u4_all.deb) ...
Selecting previously unselected package perl.
Unpacking perl (from .../perl_5.14.2-21+deb7u4_amd64.deb) ...
Selecting previously unselected package libswitch-perl.
Unpacking libswitch-perl (from .../libswitch-perl_2.16-2_all.deb) ...
Selecting previously unselected package openssh-client.
Unpacking openssh-client (from .../openssh-client_1%3a6.0p1-4+deb7u6_amd64.deb) ...
Selecting previously unselected package patch.
Unpacking patch (from .../patch_2.6.1-3_amd64.deb) ...
Selecting previously unselected package liberror-perl.
Unpacking liberror-perl (from .../liberror-perl_0.17-1_all.deb) ...
Selecting previously unselected package git-man.
Unpacking git-man (from .../git-man_1%3a1.7.10.4-1+wheezy3_all.deb) ...
Selecting previously unselected package git.
Unpacking git (from .../git_1%3a1.7.10.4-1+wheezy3_amd64.deb) ...
Selecting previously unselected package gitlab-ci-multi-runner.
Unpacking gitlab-ci-multi-runner (from .../gitlab-ci-multi-runner_1.5.3_amd64.deb) ...
Selecting previously unselected package rsync.
Unpacking rsync (from .../rsync_3.0.9-4_amd64.deb) ...
Selecting previously unselected package xauth.
Unpacking xauth (from .../xauth_1%3a1.0.7-1_amd64.deb) ...
Setting up libgdbm3:amd64 (1.8.3-11) ...
Setting up libpopt0:amd64 (1.16-7) ...
Setting up libbsd0:amd64 (0.4.2-1) ...
Setting up libedit2:amd64 (2.11-20080614-5) ...
Setting up libexpat1:amd64 (2.1.0-1+deb7u4) ...
Setting up libxau6:amd64 (1:1.0.7-1) ...
Setting up libxdmcp6:amd64 (1:1.1.1-1) ...
Setting up libxcb1:amd64 (1.8.1-2+deb7u1) ...
Setting up libx11-data (2:1.5.0-1+deb7u2) ...
Setting up libx11-6:amd64 (2:1.5.0-1+deb7u2) ...
Setting up libxext6:amd64 (2:1.3.1-2+deb7u1) ...
Setting up libxmuu1:amd64 (2:1.1.1-1) ...
Setting up openssh-blacklist (0.4.1+nmu1) ...
Setting up openssh-blacklist-extra (0.4.1+nmu1) ...
Setting up adduser (3.113+nmu3) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Setting up less (444-4) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Setting up libclass-isa-perl (0.36-3) ...
Setting up openssh-client (1:6.0p1-4+deb7u6) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Setting up patch (2.6.1-3) ...
Setting up git-man (1:1.7.10.4-1+wheezy3) ...
Setting up rsync (3.0.9-4) ...
update-rc.d: using dependency based boot sequencing
invoke-rc.d: policy-rc.d denied execution of restart.
Setting up xauth (1:1.0.7-1) ...
Setting up perl-modules (5.14.2-21+deb7u4) ...
Setting up perl (5.14.2-21+deb7u4) ...
update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode
Setting up liberror-perl (0.17-1) ...
Setting up git (1:1.7.10.4-1+wheezy3) ...
Setting up gitlab-ci-multi-runner (1.5.3) ...
GitLab Runner: creating gitlab-runner...
Setting up libswitch-perl (2.16-2) ...

서비스를 시작하려고하면 오류가 발생합니다.
조사해 보면 이미 기동하고 있다 (웃음)
# service gitlab-runner status
[ ok ] GitLab Runner is running.

프로젝트에 등록



프로젝트 측 token에서 프로젝트에 직접 등록합니다.Gitlab 위 프로젝트의 token는 프로젝트를 열고 오른쪽 상단에 표시되는 "기어 아이콘"→ "runner"를 클릭하면 적자로 token가 표시됩니다.



등록 명령


# gitlab-ci-multi-runner register
Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci):
http://gitlab/ci
Please enter the gitlab-ci token for this runner:
52h1HW-mgqwFCFrDwT4K
Please enter the gitlab-ci description for this runner:
[debian-runner]: 
Please enter the gitlab-ci tags for this runner (comma separated):

Registering runner... succeeded                     runner=52h1HW-m
Please enter the executor: shell, ssh, virtualbox, docker+machine, docker-ssh+machine, docker, docker-ssh, parallels:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

일부 등록 내용을 듣기 때문에 입력합니다.
  • http://gitlab/ci 등록하려는 gitlab 서버의 URL에 ci를 추가하여 등록 대상을 지정합니다.
  • 52h1HW-mgqwFCFrDwT4K 이것은 방금 조사한 프로젝트의 token입니다.
  • debian-runner runner 이름입니다. Gitlab 옆에 표시되어도 알 수 있도록 합시다.
  • 다음에 태그입니다만, 콤마로 복수 등록할 수 있고 여기에서는 비우고 있습니다. CI 처리에 이 태그로 처리할 때의 판단에 사용됩니다.
  • shell 이번에는 debian 위에서 달리기 위해 shell를 지정합니다.

  • 등록이 잘되면 프로젝트의 설정 화면에서 다음과 같이 됩니다.



    CI 실행



    CI 정의 파일 설정



    다음과 같이 설정 파일을 준비하고 위에서 등록한 프로젝트로 푸시합니다.

    .gitlab-ci.yaml
    image: debian:7.11
    
    stages:
      - check
      - test
      - deploy
    
    code_check:
      stage: check
      script:
        - pwd
        - whoami
    
    test1:
      stage: test
      script:
        - echo "test"
    
    deploy_production1:
      stage: deploy
      script:
        - echo "deploy(production)"
      only:
        - release/production
    
    deploy_staging1:
      stage: deploy
      script:
        - echo "deploy(staging)"
      only:
        -  release/staging
    

    실행 결과



    수행한 결과는 다음과 같습니다.
    등록을 여러 번 반복했기 때문에 위의 그림과 등록 번호가 다릅니다만, 등록한 runner의 id로 폴더가 작성되는 것 같습니다. 실행 사용자는 gitlab-runner입니다. 또한 도커편에서 사용한 image는 무시된 것 같습니다.



    관련


  • Gitlab 일본어화 (docker) 설치
  • Gitlab의 lfs
  • Gitlab에서 CI (이미지)
  • Gitlab에서 CI docker 편

  • 참고 사이트


  • Run gitlab-runner in a container
  • Install using GitLab's repository for Debian/Ubuntu/CentOS/RedHat (preferred)



  • 공식 문서 거리 

    좋은 웹페이지 즐겨찾기