小编mak*_*aki的帖子

GITLAB CI 管道未触发

我已经为 GitLab CI/CD 编写了这个 yml 文件。有一个已配置并正在运行的共享运行器。我是第一次这样做,不确定我哪里出错了。我在 repo 上的 Angular js 项目有一个 gulp 构建文件,并且在本地计算机上完美运行。此代码只需在我的运行程序所在的虚拟机上触发该代码即可。提交时管道不显示任何作业。让我知道哪些地方需要改正!

image: docker:latest

cache:
  paths:
    - node_modules/

deploy_stage:
  stage: build
  only:
    - master
  environment: stage
  script:
  - rmdir -rf "build"
  - mkdir "build"
  - cd "build"
  - git init
  - git clone "my url"
  - cd "path of cloned repository"
  - gulp build
Run Code Online (Sandbox Code Playgroud)

continuous-integration gitlab

12
推荐指数
2
解决办法
2万
查看次数

如何使用 gitlab CI/CD 设置与 MySql 数据库的连接

我正在尝试使用 CI/CD gitlab 设置 django 项目的自动测试。问题是,我无法以任何方式连接到 Mysql 数据库。

gitlab-ci.yml

services:
  - mysql:5.7

variables:
      MYSQL_DATABASE: "db_name"
      MYSQL_ROOT_PASSWORD: "dbpass"
      MYSQL_USER: "username"
      MYSQL_PASSWORD: "dbpass"
      

stages:
  - test

test:
  stage: test
  before_script:
  - apt update -qy && apt-get install -qqy --no-install-recommends default-mysql-client
  - mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST --execute="SHOW DATABASES; ALTER USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD'"
  script:
  - apt update -qy
  - apt install python3 python3-pip virtualenvwrapper -qy
  - virtualenv --python=python3 venv/
  - source venv/bin/activate
  - pwd
  - pip install -r requirement.txt …
Run Code Online (Sandbox Code Playgroud)

mysql django gitlab

11
推荐指数
2
解决办法
2万
查看次数

黄瓜-junit-平台引擎中的@CucumberOptions

我正在尝试将我的黄瓜测试迁移到 ,cucumber-junit以便cucumber-junit-platform-engine能够使用新的平台功能。如何重新定义我的跑步者以使用旧的@CucumberOptions. 我正在调查这个问题,但似乎还找不到正确的方法。

在我使用这些选项之前:

@CucumberOptions(
  plugin = ...,
  features = ...,
  tags = ...,
  glue = ...
)
Run Code Online (Sandbox Code Playgroud)

有没有直接的方法将其迁移到平台引擎?

java cucumber cucumber-junit cucumber-java junit5

7
推荐指数
1
解决办法
1万
查看次数

插件 [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] 未在以下任何来源中找到:

我刚刚从http://start.spring.io/下载了 springboot 项目。运行后我得到这个错误。

* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.4.RELEASE')
  Searched in the following repositories:
    Gradle Central Plugin Repository

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. …
Run Code Online (Sandbox Code Playgroud)

gradle spring-boot

6
推荐指数
3
解决办法
2万
查看次数

Docker compose 不会批量保存数据

我正在尝试使用 docker-compose 运行 Kafka。我得到了这个 yml 文件:

version: '3'


services:
  zookeeper:
    image: ${REPOSITORY}/cp-zookeeper:${TAG}
    hostname: zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    volumes:
      - ./zoo:/var/lib/zookeeper

  broker:
    image: ${REPOSITORY}/cp-kafka:${TAG}
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    ports:
      - "29092:29092"
      - "9092:9092"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
    volumes:
      - ./broker:/var/lib/kafka
Run Code Online (Sandbox Code Playgroud)

我在带有 docker-compose.yml 文件的目录中运行了一个命令:

docker-compose up -d
Run Code Online (Sandbox Code Playgroud)

在该文件夹之后./broker./zoo出现在我的目录中。在内部,它们具有类似于容器内部的结构 ( ./zoo/data, ./broker/data)。但是目录中没有文件。

我试过

docker-compose exec broker ls /var/lib/kafka/data …
Run Code Online (Sandbox Code Playgroud)

apache-kafka docker docker-compose

6
推荐指数
1
解决办法
1957
查看次数

如何使 Dockerfile COPY 适用于 Windows 绝对路径?

如何使COPY命令适用于 Windows 上的绝对路径?我尝试使用 git-bash、cmd 和 powershell 控制台进行构建docker build -t custom-maven-image .

# Dockerfile
FROM maven:3-openjdk-11-slim
# these are three versions of copy command I tried
COPY C:/Users/myuser/.m2 /root/.m2
COPY /C/Users/myuser/.m2 /root/.m2
COPY /c/Users/myuser/.m2 /root/.m2
Run Code Online (Sandbox Code Playgroud)

我得到的是一个错误:

...
#5 ERROR: "/C/Users/myuser/.m2" not found: not found
Run Code Online (Sandbox Code Playgroud)

更新:

谢谢@Jeremy 的错误参考,现在我看到文档清楚地说:

COPY 遵循以下规则:

该路径必须位于构建的上下文内;你不能 COPY ../something /something,因为 docker 构建的第一步是将上下文目录(和子目录)发送到 docker 守护进程。

dockerfile docker-for-windows

6
推荐指数
1
解决办法
7809
查看次数

获取异常消息的更好方法是:str(e) 与 e.args[0]?

让我们考虑一种情况,我抛出内置Exception 消息,并在处理它时存储异常消息。我知道我可以通过两种方式来做到这一点,如下例所示。

try:
    raise Exception('some message')
except Exception as e:
    value_str = str(e)
    value_args = e.args[0]
Run Code Online (Sandbox Code Playgroud)

有没有理由认为一种方法比另一种方法更好?

python exception python-3.x

5
推荐指数
1
解决办法
6346
查看次数

javascript unittests jest 库中有assertCountEqual 等效项吗?

当结果列表的顺序发生变化时,我有一个玩笑单元测试,对对象列表进行断言,这些对象在一个环境中传递,而在其他环境中失败。我正在寻找一些assertCountEqual(python)等效的jest库。我会感谢任何帮助。我尝试添加sort()到我的断言中,但列表中有自定义对象,而且它并不那么简单:expect(list1.sort()).toEqual(list2.sort());

javascript unit-testing jestjs

5
推荐指数
1
解决办法
81
查看次数

仅当引用或可变条件时才无法执行 GitLab 运行程序作业

我希望 CI 仅在我位于master合并请求计划管道 变量COVERAGE_TEST等于时执行此作业ON

c++TestCoverage:
  stage: analysis
  script: "./ciScripts/testCoverageScript.sh"
  tags:
    - framework
  dependencies:
    - c++Build
  variables:
    GIT_STRATEGY: fetch
  artifacts:
    paths:
      - ./build/test_coverage/
    expire_in: 1 week
    when: on_success
Run Code Online (Sandbox Code Playgroud)

我尝试添加以下几行:

only:
  refs:
    - master
    - merge_requests
    - schedule
  variables:
    - $COVERAGE_TEST == "ON"
Run Code Online (Sandbox Code Playgroud)

但结果实际上是 -> If ((Master || MergeRequest || ScheduledPipeline) && COVERAGE_TEST == ON)


我也尝试过:

only:
  variables:
    - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
    - $CI_PIPELINE_SOURCE == 'merge_request_event'
    - $CI_PIPELINE_SOURCE == 'schedule'
    - $COVERAGE_TEST …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci gitlab-ci-runner

5
推荐指数
1
解决办法
5267
查看次数

Cucumber-junit-platform-engine 中的特征文件发现

cucumber-junit库中,我@CucumberOptions用来定义特征文件位置:

package com.mycompany.cucumber;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
  plugin = ...,
  features = "classpath:.", // my java step definitions are in package com.mycompany.cucumber 
                            // but feature files directly in test resources 
                            // resources/is_it_friday_yet.feature
  tags = ...,
  glue = ...
)
public class CucumberRunner {
}
Run Code Online (Sandbox Code Playgroud)

我正在使用自定义 gradle 任务运行我的测试 cucumberTest

cucumberTest {
    useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)

迁移后cucumber-junit-platform-engine @CucumberOptions不再支持。

cucumberTest {
    useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)

我可以通过用属性替换plugin, tags,glue选项使其工作cucumber.filter.tagscucumber.glue, cucumber.plugin …

java cucumber gradle cucumber-junit junit5

5
推荐指数
1
解决办法
1537
查看次数