Bitbucket pipelines bitbucket管道docker运行限制的可能解决方案

Bitbucket pipelines bitbucket管道docker运行限制的可能解决方案,bitbucket-pipelines,Bitbucket Pipelines,我的集成测试高度依赖于弹性搜索,因为要在bitbucket管道上构建集成测试,我必须执行docker run命令,以便能够在集成测试期间启动弹性搜索实例 但你们中的一些人可能知道,bitbucket管道有一个限制 有关如何使用的信息,请参见Docker命令行参考 这些命令。其他命令,如docker run,当前正在运行 出于安全原因,在我们的共享构建基础架构上禁止使用 因此,考虑到我不知道如何使用内部所需的所有配置来启动我的escluster,无痛苦的脚本、映射和端口,以供集成测试使用 有人知道

我的集成测试高度依赖于弹性搜索,因为要在bitbucket管道上构建集成测试,我必须执行docker run命令,以便能够在集成测试期间启动弹性搜索实例

但你们中的一些人可能知道,bitbucket管道有一个限制

有关如何使用的信息,请参见Docker命令行参考 这些命令。其他命令,如docker run,当前正在运行 出于安全原因,在我们的共享构建基础架构上禁止使用

因此,考虑到我不知道如何使用内部所需的所有配置来启动我的escluster,无痛苦的脚本、映射和端口,以供集成测试使用


有人知道我如何才能做到这一点吗?

您可以尝试将弹性搜索图像定义为一项服务,如下所述:

您可以尝试将弹性搜索图像定义为服务,如下所述:

好的,我设法让它工作了,由于这个错误,我很难运行弹性搜索

这是通过应用config
发现类型:single node
修复的。因为我使用它进行集成测试,所以不需要在生产模式下运行ES。问题是bitbucket管道没有显示此错误的错误日志,所以我完全失明,我不得不尝试很多方法直到找到答案。因为我无法在管道上构建和运行自己的映像,所以我上传了一个带有自己配置(包括单节点配置)和脚本的映像,并将其上传到docker hub

这就是我的yaml最终的样子:

image: maven:3.3.9
    pipelines:
      default:
        - step:
            caches:
              - maven
            script:
              - docker version
              - mvn clean package verify -Dmaven.docker.plugin.skip=true -s settings.xml
            services:
              - elasticsearch

    definitions:
      services:
        elasticsearch:
          image: elastic-search-bitbucket-pipeline
    options:
      docker: true

好的,我设法让它工作,我努力运行弹性搜索,由于这个错误

这是通过应用config
发现类型:single node
修复的。因为我使用它进行集成测试,所以不需要在生产模式下运行ES。问题是bitbucket管道没有显示此错误的错误日志,所以我完全失明,我不得不尝试很多方法直到找到答案。因为我无法在管道上构建和运行自己的映像,所以我上传了一个带有自己配置(包括单节点配置)和脚本的映像,并将其上传到docker hub

这就是我的yaml最终的样子:

image: maven:3.3.9
    pipelines:
      default:
        - step:
            caches:
              - maven
            script:
              - docker version
              - mvn clean package verify -Dmaven.docker.plugin.skip=true -s settings.xml
            services:
              - elasticsearch

    definitions:
      services:
        elasticsearch:
          image: elastic-search-bitbucket-pipeline
    options:
      docker: true

对于那些仍在寻找更详细解决方案的人,我创建了一个Dockerfile,如下所示:

FROM elasticsearch:7.0.1
COPY --chown=elasticsearch:elasticsearch elasticsearch.yml /usr/share/elasticsearch/config/
在同一个文件夹中,我还创建了一个自定义配置
elasticsearch.yml

network.host: 127.0.0.1
然后,我将自定义图像添加到Docker Hub,有关如何执行此操作的更多信息,请参见此处:

现在,您可以在管道服务配置中使用自定义映像,并使用它运行测试

您还可以在
elasticsearch.yml
启用CORS:

http.cors.enabled: true
http.cors.allow-origin: "*"
设置发现类型:

discovery.type: single-node

对于那些仍在寻找更详细解决方案的人,我创建了一个Dockerfile,如下所示:

FROM elasticsearch:7.0.1
COPY --chown=elasticsearch:elasticsearch elasticsearch.yml /usr/share/elasticsearch/config/
在同一个文件夹中,我还创建了一个自定义配置
elasticsearch.yml

network.host: 127.0.0.1
然后,我将自定义图像添加到Docker Hub,有关如何执行此操作的更多信息,请参见此处:

现在,您可以在管道服务配置中使用自定义映像,并使用它运行测试

您还可以在
elasticsearch.yml
启用CORS:

http.cors.enabled: true
http.cors.allow-origin: "*"
设置发现类型:

discovery.type: single-node

您可以使用我的docker图像:

将服务添加到管道中,如下所示:

definitions:
  steps:
    - step: &run-tests
        name: Run tests
        script:
          - sleep 30 # Waiting elasticsearch. In your real pipeline you can not use it.
          - curl -XGET localhost:9250/_cat/health
        services:
          - elasticsearch
  services:
    elasticsearch:
      image: xiting/elasticsearch-bitbucket-pipeline
      variables:
        ES_JAVA_OPTS: '-Xms512m -Xmx512m'
    docker:
      memory: 2048

pipelines:
  pull-requests:
    '**':
      - step: *run-tests

您可以使用我的docker图像:

将服务添加到管道中,如下所示:

definitions:
  steps:
    - step: &run-tests
        name: Run tests
        script:
          - sleep 30 # Waiting elasticsearch. In your real pipeline you can not use it.
          - curl -XGET localhost:9250/_cat/health
        services:
          - elasticsearch
  services:
    elasticsearch:
      image: xiting/elasticsearch-bitbucket-pipeline
      variables:
        ES_JAVA_OPTS: '-Xms512m -Xmx512m'
    docker:
      memory: 2048

pipelines:
  pull-requests:
    '**':
      - step: *run-tests

这正是我现在正在尝试的,我看不到其他选项。当前在开发模式下尝试运行elasticsearch时出现问题,因为。这正是我现在正在尝试的,我看不到其他选项。当前在开发模式下尝试运行elasticsearch时出现问题,因为。