How to do different json file per branch build

Hi,

My project needs a different config.json depending on the branch it is in, I build on the protected branches master, acc and prod. So I made variables of type “File” for each branch (MASTER_CONFIG, ACC_CONFIG, PROD_CONFIG) with each their own content. But how do I make the ci build get this data and copy it to the right location? I tried copying the values before building, but it doesn’t seem to work like this. What is the correct way? My gitlab-ci for the config stage looks something like this:

master_conf:
  image: docker:stable
  stage: config
  only:
    - master
  script:
    - cp $MASTER_CONFIG config.json
  artifacts:
    paths:
      - config.js

test_conf:
  image: docker:stable
  stage: config
  only:
    - acc
  script:
    - cp $ACC_CONFIG config.json
  artifacts:
    paths:
      - config.js

prod_conf:
  image: docker:stable
  stage: config
  only:
    - prod
  script:
    - cp $PROD_CONFIG config.json
  artifacts:
    paths:
      - config.js

The logging seems to show that cp gets the content of the file instead of the file path as parameters.

I am not sure what your problem is, but can you please add these lines in some of the scripts to verify what is wrong with the variables.

script:
    - echo "$MASTER_CONFIG"
    - cat "$MASTER_CONFIG"
    - cp $MASTER_CONFIG config.json
    - ls 
    - cat config.json

You have a typo in your artifacts:paths: it should be config.json I guess.

script:
    - cp $ACC_CONFIG config.json
  artifacts:
    paths:
      - config.js