user3836484
user3836484

Reputation: 205

GitLab Runner - dynamic data in .yml

I can manage to hard code shell scripts in .yml file, so that GitLab runner can execute the .yml contents when someone perform a push to the Git repo.

I would like to explore, if the .yml file can get data from external source (e.g. mysql database), and using loops to generate the shell scripts.

something like this:-

// this is a .yml file
get some data

foreach($data as $datum)
    deploy_dev:
      stage: deploy
      script:
        - echo "Deploy to server"
        - eval $(ssh-agent)
        - ssh-add ~/.ssh/key.pem
        - ssh -p22 root@xxxx "do something"
      environment:
        name: dev
        url: http://xxxx 
      only:
        - dev 
}

If it is possible, then I can update db data -> .yml -> dynamic stages for CI/CD.

Thanks.

Upvotes: 0

Views: 257

Answers (1)

Izydorr
Izydorr

Reputation: 1991

Why don't you write a script (in any language) that does what you want and run just this script inside your CI? You can pass ENV vars to it if you need to get data from the pipeline.

Upvotes: 1

Related Questions