标签: gitlab-ci-runner

Gitlab CI如何将最新部署到特定目录

我在Gitlab中有两个项目,其中一个是另一个的子模块(让我们称之为repo"frontend-templates")(让我们称之为repo"main").我已经为"frontend-templates"回购设置了一个Gitlab CI构建.问题是我不需要测试或构建.我只需要在所需目录中部署此CI.所以,我为"frontend-templates"项目注册了一个跑步者,并将.gitlab-ci.yml添加到了根目录:

job_main:
   type: deploy
   script: echo "Do nothing"
Run Code Online (Sandbox Code Playgroud)

当我推送到我的存储库时,运行器将最新的提交提取到以下目录:

/home/gitlab-runner/builds/6231b425/0/Gasimzada/frontend-templates
Run Code Online (Sandbox Code Playgroud)

然后运行echo "Do nothing".

现在,我希望运行器将"已测试"提交部署到开发服务器,该服务器位于:

/var/www/myapp/submodules/frontend-templates
Run Code Online (Sandbox Code Playgroud)

编辑:我将脚本更改为

script: cd /var/www/myapp/submodules/frontend-templates && git pull
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误说:

无法打开/var/www/myapp/.git/modules/submodules/frontend-templates/FETCH_HEAD:权限被拒绝

这是有道理的,因为gitlab-runner用户无法访问/ var/www/myapp中的任何目录,但这对我来说是个问题,因为我想gulp在部署之后运行,所以它在从远程存储库中提取后编译必要的脚本.

我是否应该授予dev环境的根目录权限?或者还有另一种方法吗?

git gitlab gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
4425
查看次数

Gitlab公共跑步者不会运行Bower,因为以sudo运行

如何使用gitlab publicRunner在不使用sudo的情况下运行bower命令?

这是我的剧本

image: node:7
before_script:
  - npm install -g bower
  - bower install
...
Run Code Online (Sandbox Code Playgroud)

这是我从测试中得到的结果。

...
npm info ok 
$ bower install
bower ESUDO         Cannot be run with sudo

Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814

You …
Run Code Online (Sandbox Code Playgroud)

gitlab bower gitlab-ci bower-install gitlab-ci-runner

2
推荐指数
1
解决办法
995
查看次数

当提交推送到另一个项目时触发项目的构建

我在gitlab上有一个带有gitlab-runner机器的三个项目A,B,C.项目A包含gitlab-ci.yml文件,该文件在A上提交时调用脚本来构建程序:

  build:
  stage: build
  script:
    - ./build-platform.sh
Run Code Online (Sandbox Code Playgroud)

A取决于B和C项目.当在B或C上有提交时,如何在A上触发构建.我不能将B,C放在A中,我无法轻松地将build-platform.sh转换为gitlab-ci.yml文件语法.

gitlab gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
1659
查看次数

如何在gitlab-ci-runner-docker中具有docker和npm

我正在使用gitlab-ci docker:dind作为服务。

问题

我正在尝试在Gitlab-CI中运行,npm run build然后运行docker build

我可以通过以下方式在docker中使用docker进行构建:

这是我的跑步者config.toml

$ cat /etc/gitlab-runner/config.toml 
concurrent = 4
check_interval = 0

[[runners]]
  name = "developers_gitlab_school-gitlab-runner-docker"
  url = "https://school.domain.com"
  token = "cd09f40c6a4....a44751fec795e35"
  executor = "docker"
  builds_dir = "/mnt/mesos/sandbox/builds"
  cache_dir = "/mnt/mesos/sandbox/cache"
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = true
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
Run Code Online (Sandbox Code Playgroud)

这是一个例子 .gitlab-ci.yml

image: docker:latest
# image: mcasimir/dind-node-build-runner:latest

variables:
  DOCKER_DRIVER: overlay2

services:
  - docker:dind

before_script:
  - docker …
Run Code Online (Sandbox Code Playgroud)

npm gitlab docker gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
2317
查看次数

如何在Gitlab CI中使用Dockerfile

将gitlab-ci用于我的节点/反应应用程序,我试图phusion/passenger-nodejs用作基础docker映像

我可以在.gitlab-ci.yml中轻松指定它:

image: phusion/passenger-nodejs:latest

variables:
  HOME: /root

cache:
  paths:
  - node_modules/

stages:
  - build
  - test
  - deploy

set_environment:
  stage: build
  script:
    - npm install
  tags:
  - docker

test_node:
  stage: test
  script:
    - npm install
    - npm test
  tags:
    - docker
Run Code Online (Sandbox Code Playgroud)

但是,Phusion Passenger希望您在Dockerfile中进行配置更改,例如python支持,使用其特殊的init进程等。

#FROM phusion/passenger-ruby24:<VERSION>
#FROM phusion/passenger-jruby91:<VERSION>
FROM phusion/passenger-nodejs:<VERSION>
#FROM phusion/passenger-customizable:<VERSION>

# Set correct environment variables.
ENV HOME /root

# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]

# If you're using the 'customizable' variant, you need to explicitly opt-in …
Run Code Online (Sandbox Code Playgroud)

passenger gitlab docker gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
6969
查看次数

Gitlab Ci无法推动跑步者的分支

我正在尝试使用Gitlab建立CI/CD管道以下是我想要做的事情:

注意:这是一个打字稿项目

  1. 单元测试和集成测试
  2. 促进分支开发到分支集成
  3. 从分支集成构建docker镜像
  4. 部署到集成环境

这是.gitlab-ci.yml我正在使用的(i:

stages:
  - test
  - promote
  - build
  - deploy
cache:
  paths:
    - node_modules/
test:
  image: node
  stage: test
  before_script:
    - yarn
  script:
    - yarn test
promote:
  image: node
  stage: promote
  only:
    - dev
  script:
    - git push origin HEAD:integration
build
  image: node
  stage: build
  only: 
    - integration
  script: 
    - echo "build docker image from integration"
deploy:
  image: node
  stage: deploy
  only:
    - integration
  script:
    - echo "deploy integration"
Run Code Online (Sandbox Code Playgroud)

我的问题是这行git push …

gitlab gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
6588
查看次数

建立失败,但工作状态是Gitlab的成功

我的Dockerfile:

FROM mm_php:7.1

ADD ./docker/test/source/entrypoint.sh /work/entrypoint.sh
ADD ./docker/wait-for-it.sh /work/wait-for-it.sh
RUN chmod 755 /work/entrypoint.sh \
    && chmod 755 /work/wait-for-it.sh

ENTRYPOINT ["/work/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)

entrypoint.sh:

#!/bin/bash -e

/work/wait-for-it.sh db:5432 -- echo "PostgreSQL started"

./vendor/bin/parallel-phpunit --pu-cmd="./vendor/bin/phpunit -c phpunit-docker.xml" tests
Run Code Online (Sandbox Code Playgroud)

泊坞窗,compose.yml:

version: '2'
services:

  test:
    build:
      context: .
      args:
        ssh_prv_key: ${ssh_prv_key}
        application_env: ${application_env}
      dockerfile: docker/test/source/Dockerfile
    links:
      - db

  db:
    build:
      context: .
      dockerfile: docker/test/postgres/Dockerfile
    environment:
      PGDATA: /tmp
Run Code Online (Sandbox Code Playgroud)

.gitlab-ci.yml:

image: docker:latest

services:
  - name: docker:dind
    command: ["--insecure-registry=my.domain:5000 --registry-mirror=http://my.domain"]

before_script:
  - apk add --no-cache py-pip
  - pip install …
Run Code Online (Sandbox Code Playgroud)

gitlab docker gitlab-ci gitlab-ci-runner docker-compose

2
推荐指数
1
解决办法
632
查看次数

冲突.容器名称"/ gitlab-runner"已被容器使用

我正在按照本指南为我在Ubuntu 16.4上运行的GitLab服务器安装docker.

当我执行以下命令时:

docker run -d --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好.但是,当我运行下一个命令来注册本指南中的跑步者时:

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register
Run Code Online (Sandbox Code Playgroud)

我一直收到消息:

docker:来自守护程序的错误响应:冲突.容器名称"/ gitlab亚军"已经由容器"b055ded012f9d0ed085fe84756604464afbb11871b432a21300064333e34cb1d"使用.您必须删除(或重命名)该容器才能重用该名称.

但是,当我跑去docker container list查看容器列表时,它是空的.

有谁知道如何解决这个错误?

gitlab docker gitlab-ci gitlab-ci-runner ubuntu-16.04

2
推荐指数
1
解决办法
4456
查看次数

gitlab pipeline on sub projects

Suppose main project has sub-projects

MainProject/
       \-------- android
                   \-------- .gitlab-ci-android.yml
       \-------- ios
       \-------- lib
       \-------- .gitlab-ci.yml
Run Code Online (Sandbox Code Playgroud)

I want my .gitlab-ci.yml to run parallel jobs for each subfolder. My goal is to have separate .gitlab-ci.yml files. Yes, it looks messy to touch only one file when you have to configure the CI of a few projects.

What is the exact command line to run jobs from the main .gitlab-ci.yml?

I tried with , but not working

jobAndroid:
  script: "gitlab-runner exec …
Run Code Online (Sandbox Code Playgroud)

yaml gitlab gitlab-ci gitlab-ci-runner

2
推荐指数
1
解决办法
312
查看次数

gitlabRunner不适用于特定项目

我注册了gitlabRunner的11个项目。

除1个项目外,每个项目的跑步者都可以正常工作。

我第一次注册该项目的执行者,它可以工作。

但是在我提交/推送某些更改后,会发生错误并导致作业失败。

我看到一些解决方案,升级git版本可以解决问题,但我不这么认为。

因为除此项目外,所有跑步者都可以正常工作。

服务器操作系统:CentOS 7
git:1.8.3.1

首次注册亚军


在(...)上
使用gitlab-runner 11.9.2运行(...)使用Shell executor ...
在localhost.localdomain上运行...
/ home / gitlab-runner /(...)中已初始化的空Git存储库/.git/
清理存储库
将git深度设置为50的更改正在获取...
创建了新的存储库。
https://gitlab.com/(...)*
[新分支] master- > origin / master
检出(...)作为master ...
跳过Git子模块设置
$ echo“> gitlab-ci启动了”
gitlab-ci启动
$ cd / home /(..)$
echo“> git pull start ”
git pull启动
$ git pull
远程:总计0(增量0),已重用0(增量0)
已经是最新的。

工作成功




第二次提交/拉动,然后

在(...)
上运行gitlab-runner 11.9.2(...)
使用Shell executor ...
在localhost.localdomain上运行...
重新初始化/ home / gitlab-runner /(...)中的现有Git存储库/.git/
清理存储库
git深度设置为50时正在获取更改...
致命:远程源已经存在。
致命:git fetch-pack:预期的浅表

错误:作业失败:退出状态1

编辑。这是我的.gitlab-ci.yml

stages:

- deploy …
Run Code Online (Sandbox Code Playgroud)

gitlab-ci gitlab-ci-runner

2
推荐指数
4
解决办法
2348
查看次数