bitbucket-pipelines - 使用来自 Bitbucket Pipelines 的 docker-maven-plugin 将图像推送到 DockerHub
问题描述
我正在尝试设置docker-maven-plugin
,fabric8
以便可以从 Bitbucket Pipelines 使用它。
我的 pom.xml 看起来像这样:
..
..
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<dockerHost>???????????</dockerHost>
<verbose>true</verbose>
<pushRegistry>true</pushRegistry>
<authConfig>
<username>username</username>
<password>password</password>
</authConfig>
<images>
<image>
<registry>registry.hub.docker.com</registry>
<name>${dockerhub.repository}</name>
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
<tags>
<tag>${docker.tag}</tag>
</tags>
<noCache>true</noCache>
</build>
</image>
</images>
</configuration>
<executions>
...
</plugin>
这在本地运行时非常有效。我在 Bitbucket Pipelines 上遇到的错误是:
[ERROR] DOCKER> Cannot create docker access object [Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)]
是的,这是因为我不确定要在<dockerHost>
标签中添加什么,知道吗?是否需要做任何其他事情才能远程完成这项工作?
谢谢!
解决方案
我遇到了同样的问题,但是在运行依赖于 docker 图像的集成测试时。经过大量搜索,我发现了以下内容
有未记录的环境变量
$BITBUCKET_DOCKER_HOST_INTERNAL
可能对您的情况有所帮助。我选择在我的 bitbucket 管道中添加所需的 docker 图像作为服务,而不是依赖于 fabric8,如下所示
image: maven:3.8.2-jdk-11
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- maven
- sonar
script:
- mvn -f server/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectName=user-management
services:
- redis
- rabbitmq
artifacts:
- target/**
services:
redis:
image: redis
rabbitmq:
image: rabbitmq
pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
branches:
'**':
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud
如这里的文档中所述
我希望这会有所帮助
推荐阅读
- android-studio - 从 Android Studio 构建项目时无法构建节点服务器
- php - 如何从顶部修复页面上的位移
- laravel - Laravel - 查询两个具有特殊条件的模型
- node.js - 如何修复 Seriate 和 Lodash 漏洞
- python - 使用“.unique”和“value_counts()”时无法匹配两个数组的索引
- python - 如何在 PyQt5 中制作多页应用程序?
- unity3d - 如何将 Flash 影片剪辑动画转换为统一动画?
- mapbox - 如何在 Mapbox Gl JS 矢量图层中单击时突出显示特征,如第二张图像
- mongodb - MongoDB 是否为“加入”的集合使用索引?
- ios - SwiftUI 中的选择器