Gitlab CIローカルDebug

2004 ワード

Gitlab CIローカルDebug


goプロジェクトに対してgitlabのciプロファイルを構成する
image: golang:alpine

before_script:
  - go version
  - go env
  - mkdir -p workspace/src/publisher-cmd/
  - mv *.go workspace/src/publisher-cmd/
  - mv vendor workspace/src/publisher-cmd/

build:
  script:
    - export GOPATH=$PWD/workspace  
    - cd workspace/src/publisher-cmd
    - go build -o publisher-cmd_linux
    - GOOS=windows GOARCH=amd64 go build -o publisher-cmd_win
    - GOOS=darwin GOARCH=amd64 go build -o publisher-cmd_mac
    - mv publisher-cmd_linux publisher-cmd_mac publisher-cmd_linux ../../../

  artifacts:
    name: publisher-cmd
    paths:
      - publisher-cmd_linux
      - publisher-cmd_mac
      - publisher-cmd_linux

プロセスしゅつりょく
Running with gitlab-ci-multi-runner 1.8.1 (a2efdd4)
Using Docker executor with image golang:alpine ...
Using locally found image version with exactly the same ID
Pulling docker image golang:alpine ...
Running on runner-c8b90077-project-110-concurrent-0 via office...
Cloning repository...
Cloning into '/builds/xi/publisher-cmd'...
Checking out b915dc91 as master...

$ mkdir -p workspace/src/publisher-cmd/
$ mv *.go workspace/src/publisher-cmd/
$ mv vendor workspace/src/publisher-cmd/
$ export GOPATH=$PWD/workspace
$ cd workspace/src/publisher-cmd
$ go build -o publisher-cmd_linux
$ GOOS=windows GOARCH=amd64 go build -o publisher-cmd_win
$ GOOS=darwin GOARCH=amd64 go build -o publisher-cmd_mac
$ mv publisher-cmd_linux publisher-cmd_mac publisher-cmd_linux ../../../
mv: can't rename 'publisher-cmd_linux': No such file or directory
ERROR: Build failed: exit code 1

gitlab ciの構成中にエラーが発生しました.ローカルdebugで、ローカルでgitlab-runner を実行する必要があります.
インストールgitlab-runner Install on macOS-GitLab Documentation
上の配置で走るjobはbuildです
プロジェクトディレクトリで実行
$ gitlab-runner exec docker build

ローカル変更buildをあなたのjobの名前に置き換えればいいです.