gpt4 book ai didi

continuous-integration - 从登台部署到生产时只运行集成测试

转载 作者:行者123 更新时间:2023-12-04 08:43:16 26 4
gpt4 key购买 nike

我的 gitlab 项目中有 3 个主要分支:dev , staging , production .我在 .gitlab-ci.yml 中使用 postman newman 进行这样的集成测试:

postman_tests:
stage: postman_tests
image:
name: postman/newman_alpine33
entrypoint: [""]
only:
- merge_requests
script:
- newman --version
- newman run https://api.getpostman.com/collections/zzz?apikey=zzz --environment https://api.getpostman.com/environments/xxx?apikey=xxxx

此脚本仅在从 dev 到 staging 或 staging 到 production 的合并请求批准过程中运行。问题是我只需要在从登台到生产的合并请求批准过程中运行这个 postman Newman 测试,我怎样才能做到这一点?

最佳答案

这可以使用“高级” only/except 设置结合提供的环境变量来实现:

postman_tests:
stage: postman_tests
image:
name: postman/newman_alpine33
entrypoint: [""]
only:
refs:
- merge_requests
variables:
- $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "staging"
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "production"
script:
- newman --version
- newman run https://api.getpostman.com/collections/zzz?apikey=zzz --environment https://api.getpostman.com/environments/xxx?apikey=xxxx

有关预定义环境变量的完整列表,您可以访问 here

关于continuous-integration - 从登台部署到生产时只运行集成测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57247066/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com