几周前我在这里得到了一些关于 gitlab ci 的大力帮助,因为我以前从未使用过它。我已经取得了不错的进展,现在到了最后一部分,将 Gulp 的输出包含在工件 zip 中。
所以目前我的构建 .yml 文件如下所示:
cache:
paths:
- vendor/
- node_modules/
before_script:
# Install git (the php image doesn't have it) which is required by composer
- apt-get update -yqq
- apt-get install git unzip -yqq
- apt-get install php-pear -yqq
# Install composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# Setup PHPCompatibility for php_codesniffer
- mkdir --parents vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
- cp -R vendor/wimg/php-compatibility/* vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
stages:
- compatibility_test
- coding_standards
- …Run Code Online (Sandbox Code Playgroud) 我在将使用 gitlab-runner 构建的映像推送到 gitlab 存储库时遇到问题。
我的 gitlab-ci.yml:
image: docker:latest
services:
- docker:dind
stages:
- build
- release
variables:
TEST_IMAGE: registry.gitlab.com/myhost/haproxy:$CI_COMMIT_REF_NAME
RELEASE_IMAGE: registry.gitlab.com/myhost/haproxy:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN gitlab.com
build:
stage: build
script:
- docker build --pull -t $TEST_IMAGE .
- docker push $TEST_IMAGE
release:
stage: release
script:
- docker pull $TEST_IMAGE
- docker tag $TEST_IMAGE $RELEASE_IMAGE
- docker push $RELEASE_IMAGE
only:
- master
Run Code Online (Sandbox Code Playgroud)
docker 登录有效 - 我得到“登录成功” - 但当涉及到推送操作时,我得到:
$ docker push $TEST_IMAGE
The push refers to …Run Code Online (Sandbox Code Playgroud) CI/CD 管道在 Ubuntu 18.04 上使用运行器和 shell 执行器在 gitlab 中设置。从管道脚本执行 docker 命令时,会抛出权限被拒绝错误。
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
Run Code Online (Sandbox Code Playgroud)
已将gitlab-runner用户添加到根组,但问题仍未解决。
gitlab-runner也已经以用户身份运行root。
root 4534 0.5 2.2 36908 23060 ? Ssl 14:02 0:02 /usr/lib/gitlab-runner/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner
Run Code Online (Sandbox Code Playgroud)
非常感谢任何解决此问题的帮助
找到答案了
usermod -aG docker gitlab-runner
sudo service docker restart
美好的一天,同事们。我在生产中使用 gitlab ci。我有很多阶段。1)构建artifactory 2)部署到外部服务器 3)使用jfrog cli部署到artifactory
我在缓存 Maven 本地存储库时遇到问题。我的跑步者在第一步(构建)中下载所有依赖项,并在最后一步(部署到神器)中执行相同的操作。另外,我的跑步者在最后阶段之前删除了 m2 文件夹中的所有数据:
Removing .m2/antlr/
Removing .m2/aopalliance/
Removing .m2/asm/
Removing .m2/avalon-framework/
Removing .m2/backport-util-concurrent/
Removing .m2/ch/
Removing .m2/classworlds/
Removing .m2/com/
Removing .m2/commons-beanutils/
Removing .m2/commons-chain/
Removing .m2/commons-cli/
Removing .m2/commons-codec/
Removing .m2/commons-collections/
Removing .m2/commons-digester/
Removing .m2/commons-io/
Removing .m2/commons-lang/
Removing .m2/commons-logging/
Removing .m2/commons-validator/
Removing .m2/dom4j/
Removing .m2/io/
Removing .m2/javax/
Removing .m2/junit/
Removing .m2/log4j/
Removing .m2/logkit/
Removing .m2/net/
Removing .m2/org/
Removing .m2/oro/
Removing .m2/sslext/
Removing .m2/xml-apis/
Removing .m2/xmlunit/
Removing jfrog
Removing target/
Run Code Online (Sandbox Code Playgroud)
我的 gitlav-ci yaml(没有第二步):
stages:
- …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ansible 完全部署我的 gitlab CICD 堆栈并自动注册运行程序。
我在我的剧本中使用以下任务来获取注册令牌并将其存储在事实中以供我的跑步者进一步注册,正如我在几个教程中看到的那样,我们可以从 gitlab 数据库获取注册令牌。
ansible 剧本任务:
- name: Extract Runner Registration Token directly from Gitlab DB
become: true
become_user: gitlab-psql
vars:
ansible_ssh_pipelining: true
query: "SELECT runners_registration_token FROM application_settings ORDER BY id DESC LIMIT 1"
psql_exec: "/opt/gitlab/embedded/bin/psql"
gitlab_db_name: "gitlabhq_production"
shell: '{{ psql_exec }} -h /var/opt/gitlab/postgresql/ -d {{ gitlab_db_name }} -t -A -c "{{ query }}"'
register: gitlab_runner_registration_token_result
Run Code Online (Sandbox Code Playgroud)
但此任务不会取回任何注册令牌(获取空字符串),因为application_settings表中不存在runners_registration_token列。但是该列存在,但返回的字符串被api 拒绝。runners_registration_token_encryptedrunners_registration_token_encryptedrunner-register
因此,我必须从 gitlab gui(在admin/runners中)复制跑步者注册令牌,将其硬编码到剧本中并再次运行剧本以成功注册堆栈。
有人可以解释一下 gitlab 在哪里存储 …
我是 gitlab 的新手,所以对它没有太多了解。
我正在尝试设置 gitlab 在构建图像之前运行测试。npm我已经设置了一个配置正确的私人运行器,我可以构建图像,但如果我运行命令来测试代码,它就不起作用。这是我的gitlab-ci.yml文件。
image: docker:latest
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
stages:
- build-container-test
- test-run
build-container-test:
stage: build-container-test
script:
- docker build -t "$IMAGE_TAG" .
- docker push "$IMAGE_TAG"
only:
- test
test-run:
stage: test-run
script:
- npm run test
only:
- test
Run Code Online (Sandbox Code Playgroud)
我是否需要npm在 gitlab runner 上单独安装才能运行它,还是我在这里遗漏了一些东西?
continuous-integration node.js gitlab gitlab-ci gitlab-ci-runner
我的环境是 Centos 7,我刚刚安装了 gitlab-runner,当我作为安装 gitlab-runner 的用户(而不是 root)运行此命令时
sudo gitlab-runner register
Run Code Online (Sandbox Code Playgroud)
这将导致找不到命令,但如果我在没有 sudo 的情况下运行
gitlab-runner register
Run Code Online (Sandbox Code Playgroud)
它运行但显示了这一行
WARNING: Running in user-mode.
WARNING: The user-mode requires you to manually start builds processing:
WARNING: $ gitlab-runner run
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...
Run Code Online (Sandbox Code Playgroud)
有人知道如何解决这个问题吗
我有一个 GitLab CI 作业,使用自定义环境运行一系列 Postman 请求。我使用 Newman 与newman-reporter-htmlextra npm 插件一起运行它们以生成测试报告。
该工作如下所示:
postman-tests:
stage: postman-tests
image:
name: wojciechzurek/newman-ci
before_script:
- cd ci/tests/postman
- npm install -g newman-reporter-htmlextra
script:
- newman run Non-regression_tests.postman_collection.json -e Tests.postman_environment.json \
--reporters htmlextra --reporter-htmlextra-export newman-results.html
- ls -la # Check report generation
artifacts:
when: always
paths:
- newman-results.html
allow_failure: true
Run Code Online (Sandbox Code Playgroud)
当我在我的 mac (newman 4.5.0) 上运行 newman 时,请求和相关测试正常运行并生成报告。但是,作业失败并且未生成报告:
$ newman run Non-regression_tests.postman_collection.json -e Tests.postman_environment.json --reporters htmlextra --reporter-htmlextra-export newman-results.html --color
Uploading artifacts...
WARNING: newman-results.html: no matching files
ERROR: …Run Code Online (Sandbox Code Playgroud) 我想为我的项目设置 CI/CD。我的问题是当 Laravel 开始迁移时会发生此错误:
在我的 gitlab-ci 文件中,我测试了 localhost、127.0.0.01 和图像名称 (mcr.microsoft.com/mssql/server) 作为 DB-Host 和 MSSQL-Host 的主机。它们都不起作用。我不知道是因为 docker 和 gitlab 或 Dockerfile 配置之间的网络问题。
这是我的 Dockerfile:
# Set the base image for subsequent instructions
FROM php:7.3
# Update packages
RUN apt-get update
# Install PHP and composer dependencies
RUN apt-get install gnupg -qq git wget curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev
libbz2-dev libzip-dev
# Clear out the local repository of retrieved package files
RUN apt-get clean
# Install needed extensions
# Here you can …Run Code Online (Sandbox Code Playgroud) 我对 Gitlab CI/CD 非常陌生,我非常仔细地阅读了它的文档,其中有关使用 file.js 创建新的 CI/CD 进程.gitlab-ci.yml。正如我发现的,为了进行持续部署(也称为 CD),需要在我的 linux 服务器上注册一个新的 gitlab-runner。
解释
这是我的.gitlab-ci.yml文件:
stages:
- build
- deploy
docker-build:
image: docker:stable
services:
- docker:dind
stage: build
only:
refs:
- ci-test
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
- echo $CI_REGISTRY_IMAGE
- echo $CI_COMMIT_SHORT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
deploy:
image: docker:stable
stage: deploy
services:
- …Run Code Online (Sandbox Code Playgroud) continuous-integration continuous-deployment continuous-delivery gitlab-ci gitlab-ci-runner