我想在gitlab-ci.yml中使用newman设置部署前邮递员测试,如果测试通过,则将部署,如果测试失败,则将取消部署。
这是我的.gitlab-ci.yml文件-
variables:
POSTMAN_COLLECTION : collection.json
POSTMAN_ENVIRONMENT: postman-test.postman_environment.json
stages:
- build
- test
build:
stage: build
script:
- docker build -t registry.tech5-sa.com/t5-platform/t5-templates-db_app:$CI_COMMIT_REF_NAME --build-arg UID=$(id -u) -f API/Dockerfile .
- docker build -t registry.tech5-sa.com/t5-platform/t5-templates-db_postgresql:$CI_COMMIT_REF_NAME --build-arg UID=$(id -u) -f API/Dockerfile.postgresql .
- docker push registry.tech5-sa.com/t5-platform/t5-templates-db_app:$CI_COMMIT_REF_NAME
- docker push registry.tech5-sa.com/t5-platform/t5-templates-db_postgresql:$CI_COMMIT_REF_NAME
tags:
- t5
- t5-templates-db
stage: test
image:
name: postman/newman_alpine33
entrypoint:[""]
before_script:
- docker login -u "$CI_REGISTRY_USER" -P "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker-compose up
- newman --version
- newman run ${POSTMAN_COLLECTION} -e ${POSTMAN_ENVIRONMENT}
答案 0 :(得分:1)
我认为您的做法正确。只需添加另一个阶段,例如像这样部署:
stages:
- build
- test
- deploy
build:
stage: build
script: echo "Building the app"
test:
stage: test
script: echo "Running tests"
deploy:
stage: deploy
script: echo "Deploying the app"
分配给这些阶段的作业将按此顺序运行。如果任何作业失败,则管道将失败,分配给下一阶段的作业将不会运行。
查看更多Discount on specific products based on a daily time range in Woocommerce