带有testContainer的Bitbucket管道无法正常工作
尝试使用测试容器运行Bitbucket管道时,我会面临此错误
无法启动容器java.lang.illegalstateexception:容器 无法正确启动。
没有其他问题,但也许与绑定有关?日志:
“ hostconfig”:“ binds”:[“/opt/opt/atlassian/pipelines/agent/build/src/test/resources:/opt/opt/atlassian/pipelines/agent/agent/agent/build/src/test/test/resources:rw“,rw”, “ /var/run/docker.sock :/docker.sock :rw“]
pipelines config:
pipelines:
pull-requests:
'**':
- step:
name: Integration tests
caches:
- maven
after-script:
- pipe: atlassian/checkstyle-report:0.3.0
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export TESTCONTAINERS_CHECKS_DISABLE=true
- mvn -B verify -Dsurefire.skip=true --file pom.xml
services:
- docker
- step:
name: Build
caches:
- maven
after-script:
- pipe: atlassian/checkstyle-report:0.3.0
script:
- mvn -B package --file pom.xml -DskipTests
services:
- docker
definitions:
services:
docker:
memory: 3072
docker-compose.yml
services:
db:
image: postgres:14.1
ports:
- "5432:5432"
expose:
- "5432"
networks:
- example-network
environment:
- "POSTGRES_USER=${DB_USER:-postgres}"
- "POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}"
- "POSTGRES_DB=${DB_SCHEMA:-testdb}"
logging:
driver: json-file
options:
mode: "non-blocking"
networks:
example-network:
driver: bridge
docker docker compose compose compose coptaine:
DOCKER_COMPOSE_CONTAINER =
new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"))
.withExposedService(SERVICE_NAME, SERVICE_PORT,
Wait.forListeningPort());
DOCKER_COMPOSE_CONTAINER.start();
我也没有testcontainers_checks_checks_disable = true = true,但是那里是错误的
状态403:{“消息”:“插件管道拒绝授权:-v仅支持$ bitbucket_clone_dir及其子目录”}
任何人都可以帮忙吗?
I face this error when try to run bitbucket pipelines with test container
Could not start container java.lang.IllegalStateException: Container
did not start correctly.
There is no another issues but maybe it's related to Binds? Logs:
"HostConfig":"Binds":["/opt/atlassian/pipelines/agent/build/src/test/resources:/opt/atlassian/pipelines/agent/build/src/test/resources:rw","/var/run/docker.sock:/docker.sock:rw"]
Pipelines config:
pipelines:
pull-requests:
'**':
- step:
name: Integration tests
caches:
- maven
after-script:
- pipe: atlassian/checkstyle-report:0.3.0
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export TESTCONTAINERS_CHECKS_DISABLE=true
- mvn -B verify -Dsurefire.skip=true --file pom.xml
services:
- docker
- step:
name: Build
caches:
- maven
after-script:
- pipe: atlassian/checkstyle-report:0.3.0
script:
- mvn -B package --file pom.xml -DskipTests
services:
- docker
definitions:
services:
docker:
memory: 3072
docker-compose.yml
services:
db:
image: postgres:14.1
ports:
- "5432:5432"
expose:
- "5432"
networks:
- example-network
environment:
- "POSTGRES_USER=${DB_USER:-postgres}"
- "POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}"
- "POSTGRES_DB=${DB_SCHEMA:-testdb}"
logging:
driver: json-file
options:
mode: "non-blocking"
networks:
example-network:
driver: bridge
docker compose container:
DOCKER_COMPOSE_CONTAINER =
new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"))
.withExposedService(SERVICE_NAME, SERVICE_PORT,
Wait.forListeningPort());
DOCKER_COMPOSE_CONTAINER.start();
I also tried without TESTCONTAINERS_CHECKS_DISABLE=true but there was error like
Status 403: {"message":"authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"}
Could anyone help with this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您收到的错误消息所解释的那样,Bitbucket Pipelines Docker Engine仅允许您的项目源的子目录。
我不知道为什么您打算安装/var/run/docker.sock,或者是否可以避免它,但是Bitbucket通常将Docker Engine转发到产卵容器中,例如,管道中的是通过设置,
因此可能需要模仿那。
As the error message you got explains, Bitbucket Pipelines Docker engine only lets mounting subdirectories of your project sources.
I don't know why you intend to mount /var/run/docker.sock or if you can avoid it, but the way Bitbucket usually forwards the Docker engine to spawned containers, e.g. in pipes, is by setting
so might need to imitate that.