我的gitlab项目中有3个主要分支:dev
,staging
和production
。我在.gitlab-ci.yml
中使用邮递员纽曼进行集成测试:
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
此脚本仅在从开发到暂存或从暂存到生产的合并请求批准过程中运行。问题是,当合并请求从暂存到生产的审批过程中,我仅需要运行此邮递员纽曼测试,我该如何实现?
答案 0 :(得分:0)
这可以通过仅使用“高级” /设置与提供的环境变量结合使用来实现:
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