Any way to export environment vars during build?


#1

Hi everybody!

Actually, the problem I’m trying to solve is to filter $CI_BRANCH variable and replace some symbols (like -/.*, etc) with “_”. I was thinking about some pre-processing step where I can modify $CI_BRANCH and store new value to another env variable. Is it possible to do so? Any other workaround?


#2

Hey @Ivan,

sorry for the slow reply on this topic.

You could use shared host volumes (see https://documentation.codeship.com/pro/getting-started/docker-volumes/#configuration-2-passing-data-between-steps) to pass data between different steps (or containers).

That way you could have a container, that takes the CI_BRANCH environment variable as input, transforms it according to your rules and writes the generated data to a file on the shared volume. A later step could then source that file and get access to the modified version.

Would that work in your case?


#3

Hi @mlocher!

Thanks for the tip, it worked for me. I just thought that there is another approach to solve such a problem.

Regards,
Ivan.


#4

Not at the moment. But I’ll ask our @product team to look into this :slight_smile: