我已经设置了GitLab-CI,并且正在编写我的代码.gitlab-ci.yml来运行测试。我的应用程序是用node.js编写的,文件如下所示:
before_script:
- npm install
- node server.js
stages:
- test
job_name:
stage: test
script:
- npm run test
Run Code Online (Sandbox Code Playgroud)
我在启动服务器然后运行测试时遇到了麻烦,因为node server.js创建了一个前台进程,除非您手动执行,否则它永远不会存在。有没有一种方法可以启动服务器,然后继续运行,然后在测试完成后将其停止?
还是我实际上做错了,我的服务器应该自己开始进行测试吗?我读过的所有内容都只是说“然后在另一个终端中启动节点,然后对本地服务器运行测试”,但这在自动化CI系统中显然毫无意义吗?
我在LaTeX大学写下讲座(这对于这个目的非常方便),我希望tex文件自动编译pdf.
.tex我的存储库中有几个文件,如下所示:
.
??? .gitlab-ci.yml
??? lectures
??? math
| ??? differentiation
| | ??? lecture_math_diff.tex
| | ??? chapter_1.tex
| | ??? chapter_2.tex
| ??? integration
| ??? lecture_math_int.tex
| ??? chapter_1.tex
| ??? chapter_2.tex
??? physics
??? mechanics
??? lecture_physics_mech.tex
??? chapter_1.tex
??? chapter_2.tex
Run Code Online (Sandbox Code Playgroud)
所以主文件,例如,lecture_math_diff.tex使用
\include{chapter_1}
\include{chapter_2}
Run Code Online (Sandbox Code Playgroud)
标签,形成整个讲座.
结果,我想在pdf中使用这样的构建工件:
??? math
| ??? lecture_math_diff.pdf
| ??? lecture_math_int.pdf
??? physics
??? lecture_physics_mech.pdf
Run Code Online (Sandbox Code Playgroud)
这可以做什么?我是否必须编写任何sh脚本来收集所有tex文件或使用gitlab runners?
我按照本指南创建了一个特定的运行程序:使用官方GitLab存储库(Linux)进行安装.我能够在我们公司的GitLab中成功注册跑步者.
我还为我们的gradle项目提供了一个.gitlab-ci.yml.基本上它就像这样简单:
image: java:8-jdk
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
build:
stage: build
script:
- ./gradlew assemble
test:
stage: test
script:
- ./gradlew check
Run Code Online (Sandbox Code Playgroud)
一旦GitLab看到这个文件就开始运行一个构建但是失败了:
$ ./gradlew assemble
Downloading https://services.gradle.org/distributions/gradle-2.12-bin.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org
Run Code Online (Sandbox Code Playgroud)
我通过更新本地/etc/gitlab-runner/config.toml中的extra_hosts解决了这个问题:
[runners.docker]
tls_verify = false
image = "ruby:2.1"
privileged = false
disable_cache = false
volumes = ["/cache"]
extra_hosts = ["git.my.company.com:xxx.xxx.xxx.xxx","services.gradle.org:207.223.250.8","downloads.gradle.org:54.240.162.161","repo1.maven.org:151.101.36.209"]
[runners.cache]
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我必须为构建期间使用的每个主机名执行此操作.现在我可以使用GitLab CI运行构建,但我必须提供这种繁琐的设置.我宁愿看到跑者从DNS中提取IP地址.
有没有人遇到过同样的问题?有没有已知的解决方案?
提前致谢
编辑
我可以将DNS设置添加到跑步者配置中,如下所示:
[runners.docker]
tls_verify = false
image = "ruby:2.1"
privileged = false
disable_cache …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个docker runner并成功注册了gitlab-ce的跑步者.但是,当作业运行时,它始终会失败并显示以下内容:
Running with gitlab-ci-multi-runner 1.10.2 (d171b73)
Using Docker executor with image python:3.4 ...
Starting service postgres:latest ...
Pulling docker image postgres:latest ...
Waiting for services to be up and running...
Pulling docker image python:3.4 ...
Running on runner-b35ff618-project-96-concurrent-0 via toucan...
Cloning repository...
Cloning into '/builds/amrstratus/webportal'...
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.xxxxxxxxx/amrstratus/webportal.git/': Failed to connect to gitlab.xxxxxx port 443: Connection refused
ERROR: Build failed: exit code 1
Run Code Online (Sandbox Code Playgroud)
我试图简单地克隆存储库并得到类似的错误:
root@toucan:/tmp# git clone https://gitlab-ci-token:b35ff618453c702944c736668e1c2c@gitlab.xxxxxxxx/amrstratus/webportal.git/
Cloning into 'webportal'...
remote: HTTP Basic: Access denied
fatal: …Run Code Online (Sandbox Code Playgroud) 我正在使用Blackbox保护存储库中的敏感文件,但对于我来说,突然,莫名其妙地,它只是停止了工作。
我正在运行一个GitLab CI部署脚本,blackbox_postdeploy失败并显示message gpg: [don't know] ctb=00。
我已经发现ctb=00通常与损坏的钥匙串有关,但是由于我是在干净的Docker容器上(通过GitLab CI)运行它,所以我不知道如何解决它。
这是GitLab CI脚本的输出:
$ gpg -v --import <(echo "$GPG_PRIVATE_KEY")
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: pub 4096R/ABC1234 2017-04-28 Bot <bot@redacted.com>
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: using PGP trust model
gpg: key ABC1234: public key "Bot <bot@redacted.com>" imported
gpg: Total number …Run Code Online (Sandbox Code Playgroud) 我需要使用gitlab页面托管一个静态网站.我的repo是一个私有存储库(或项目).gitlab-ci.yml,我尝试使用的是这样的:
image: gpecchio:BeCall
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- private
only:
- master
Run Code Online (Sandbox Code Playgroud)
我认为这image是错的,但我不知道要改变它的内容.我做了一些研究,但GitLab页面没有那么多的在线教程.我怎么能改变这个文件才能使它工作?
其他可能有用的信息:
GitLab用户名:gpecchio
GitLab项目名称:BeCall
GitLab项目网址:https://gitlab.com/gpecchio/BeCall
我目前正在使用无服务器框架并使用共享运行程序设置gitlab ci.
以下是我的gitlab-ci.yml:
image: node:latest
services:
- redis
cache:
paths:
- node_modules/
- java/
stages:
- build
- test
- review
- staging
- production
build:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
install:java:
stage: build
script:
- apt-get update
- apt-get install -y default-jre default-jdk openjdk-7-jre openjdk-7-jdk
- apt-get update
- sls dynamodb install
artifacts:
paths:
- java/
connect:
image: redis
script:
- redis-cli -h redis PING
unit test:
stage: test
script:
- sls dynamodb start …Run Code Online (Sandbox Code Playgroud) continuous-integration redis gitlab gitlab-ci gitlab-ci-runner
(我看到有很多与此有关的问题,但我还没有找到能解决我确切问题的方法)。
我正在运行gitlab-ci,当运行程序签出我的代码时,它作为分离的头部运行。这是在运行程序git status目录中运行命令时得到的信息。
git status
# HEAD detached at 847fe59
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
对于我正在做的事情,我需要做的是将该头重新附加到我的开发分支,然后git pull在完整的存储库中使用,以在Docker容器中使用。我猜gitlab ci只签出最后一次提交以保存克隆完整的回购,这是可以理解的。
在我的.gitlab-ci.yml文件中,我尝试了以下操作...
- git checkout origin/$CI_BUILD_REF_NAME
- git pull
Run Code Online (Sandbox Code Playgroud)
在控制台中提供以下输出...
$ git checkout $CI_BUILD_REF_NAME
Switched to a new branch 'develop'
Branch develop set up to track remote branch develop from origin.
$ git pull
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
Run Code Online (Sandbox Code Playgroud)
Is there …
我正在设置一个Symfony 4.2.2应用程序,并且想要使用Gitlab-CI运行功能测试。但是我面临着这个问题:
A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
奇怪的是,我在本地遇到此问题,但是只有在缓存重建后第一次运行单元测试时才出现。第二次运行单元测试时,不再触发错误。
我使用SENSIO /框架-EXTRA束的5.2.4版本,它应该有解决这个问题,因为说这里。
此错误使我的工作每次都失败,即使所有测试都可以。
我确保Symfony\Bundle\FrameworkBundle\Test\WebTestCase在功能测试中使用该类。我还确保所有依赖项都是最新的。
这是我编写的功能测试的示例:
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* Class MigrationControllerTest
*
* @group functional
*/
class MigrationControllerTest extends WebTestCase
{
public function testNotAllowed()
{
$client = static::createClient();
$client->request('UPDATE', '/migrate');
$this->assertEquals(405, $client->getResponse()->getStatusCode());
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的CI配置:
image: my.private.repo/images/php/7.2/symfony:latest
cache:
paths:
- vendor/
before_script:
- composer install
services:
- mysql:5.7
unit_test:
script: …Run Code Online (Sandbox Code Playgroud) 我们的存储库中有一个CI管道,托管在gitlab中
我们在本地机器上设置gitlab-runner
管道运行4个步骤
建立
单元测试
所有这些流水线需要将近20分钟
并在每次推送到分支时触发管道
有没有一种配置gitlab-runner的方法,如果当前运行的运行器所在的分支的HEAD发生变化,管道将自动取消运行?因为最新版本很重要
例如,在此运行中,不需要较低的运行
gitlab-ci.yml
stages:
- build
- unit_tests
- unit_and_integration_tests
- quality_tests
build:
stage: build
before_script:
- cd projects/ideology-synapse
script:
- mvn compile
unit_and_integration_tests:
variables:
GIT_STRATEGY: clone
stage: unit_and_integration_tests
only:
- /^milestone-.*$/
script:
- export RUN_ENVIORMENT=GITLAB_CI
- export MAVEN_OPTS="-Xmx32g"
- mvn test
- "cat */target/site/jacoco/index.html"
cache: {}
artifacts:
reports:
junit:
- "*/*/*/target/surefire-reports/TEST-*.xml"
unit_tests:
variables:
GIT_STRATEGY: clone
stage: unit_tests
except:
- /^milestone-.*$/
script:
- export MAVEN_OPTS="-Xmx32g"
- mvn test
- "cat …Run Code Online (Sandbox Code Playgroud) continuous-integration continuous-deployment gitlab gitlab-ci gitlab-ci-runner