I have a container that I’m using in one my stages that logs out an ID, that I need to capture into a file.
What’s the reccommended way to do this with GitLab. I’m currently trying this:
Right, so no matching file is a slightly different error. It sounds like maybe the path to .env is wrong. Personally, I would be inclined to put the call to ./main in your script, but at this stage you might want to replace that with something like:
Not a single thing is outputted when I use script, oddly. I also can’t run ./main -results=false from the script either, because I get /bin/sh: eval: line 128: ./main: not found. ls lists the contents of the repo this .gitlab-ci file is in. Rather than the container being used in this stage.
This container I’m using in this stage is not related to the source of this repo. It just does some API things and setups up new test runs etc, it’s just a throw-away container that accepts some variables to construct the right API calls… So the only way I managed to run it was using the image:entrypoint. But it seems I can’t access or i don’t know where the resultant >> .env ends up, but it isn’t in /builds/group/project-name, which does make sense
Ah right, because you override entrypoint you are not starting in the normal directory that the runner would choose to clone your code. You can set the variable GIT_STRATEGY: none if you don’t want the code to be cloned at all.
So, presumably the .env file will go on the WORKDIR of your image?
So essentially the stage default dir is the builds/group/project. So I needed to make sure I ran main from the root and create the .env into the $CI_PROJECT_DIR. Now the dotenv report seems to make these variables available at to the following stage, whereas the artifacts:path does not. So that is what I wanted and all seems ok. Though, feel free to correct me if something seems wrong
You only need to define an environment if you are deploying something or preparing for a deployment. If you are just generating a file, personally I wouldn’t bother.
Reports are for tests, lints, etc where you want to display how many tests pass, paths are for files that you want to pass to future stages. I think what you want here is:
and the dependencies key will pass the artifacts between stages.
The full reference for CI files is long, but it’s worth having it open while you’re working on these things, because there are some subtleties that are well documented (e.g. around environments) and several keys have alternatives.