Gitlab CI上的Docker runner-仅用于特定阶段的代理

Gitlab CI上的Docker runner-仅用于特定阶段的代理,docker,continuous-integration,gitlab,gitlab-ci,Docker,Continuous Integration,Gitlab,Gitlab Ci,对于“部署”阶段,我需要一个代理。但阶段“测试”并不从业力测试开始的地方起作用。有没有一种方法可以定义:对阶段“部署”使用代理设置,而不是对“测试”使用代理设置 我试图从代理中排除因果报应使用的IP,但IP每次都在变化 variables: http_proxy: "$CODE_PROXY" https_proxy: "$CODE_PROXY" no_proxy: "127.0.0.1,localhost&qu

对于“部署”阶段,我需要一个代理。但阶段“测试”并不从业力测试开始的地方起作用。有没有一种方法可以定义:对阶段“部署”使用代理设置,而不是对“测试”使用代理设置

我试图从代理中排除因果报应使用的IP,但IP每次都在变化

variables:
      http_proxy: "$CODE_PROXY"
      https_proxy: "$CODE_PROXY"
      no_proxy: "127.0.0.1,localhost"

stages:
  - test
  - deploy


test:
  stage: test
  image: node:erbium
  services:
    - selenium/standalone-chrome:3.141.59
  script:
    - npm ci
    - npm run lint
    - npm run lint:sass
    - npm run lint:editorconfig
    - npm run test -- --progress=false --code-coverage
    - npm run e2e -- --host=$(hostname -i)
    - npm run build:prod -- --progress=false
  coverage: '/Statements\s*:\s*(\d+\.?\d+)\%/'
  artifacts:
    expire_in: 3h
    paths:
      - dist/
    reports:
      junit: dist/reports/app-name/test-*.xml
      cobertura: dist/coverage/app-name/cobertura-coverage.xml
  tags:
    - DOCKER

deploy:
  stage: deploy
  image: python:latest
  script:
  - pip install awscli
  - aws s3 rm s3://$S3_BUCKET_NAME --recursive
  - aws s3 cp ./dist/app-name s3://$S3_BUCKET_NAME/ --recursive
  only:
  - master
双向

  • 混合变量
  • 扩展作业模板

  • 非常感谢你。我像爬虫一样在谷歌上搜索过,但没有找到这样的东西。你的解决方案正是我想要的。
    .proxy-variables: &proxy-variables
          http_proxy: "$CODE_PROXY"
          https_proxy: "$CODE_PROXY"
          no_proxy: "127.0.0.1,localhost"
    
    deploy:
      stage: deploy
      image: python:latest
      variables:
        - *proxy-variables
      script:
        - pip install awscli
        - aws s3 rm s3://$S3_BUCKET_NAME --recursive
        - aws s3 cp ./dist/app-name s3://$S3_BUCKET_NAME/ --recursive
      only:
        - master
    
    
    .proxied-job:
      variables:
          http_proxy: "$CODE_PROXY"
          https_proxy: "$CODE_PROXY"
          no_proxy: "127.0.0.1,localhost"
    
    deploy:
      extends: .proxied-job
      stage: deploy
      image: python:latest
      script:
        - pip install awscli
        - aws s3 rm s3://$S3_BUCKET_NAME --recursive
        - aws s3 cp ./dist/app-name s3://$S3_BUCKET_NAME/ --recursive
      only:
        - master