Version: Gitlab self-managed v12.8.1 omnibus, runners using docker executor
Relevant parts of pipeline:
default: image: name: hashicorp/packer:light entrypoint: ['/bin/sh','-c'] webservers-build: stage: build-ami script: - /bin/packer build webservers/amazonlinux.json artifacts: paths: - packer.log expire_in: 1 week
I’ve built a pipeline that uses the hashicorp/packer:light container to build an AMI on AWS for me. That part of the process works great. The end of the output of the packer command is this:
==> Builds finished. The artifacts of successful builds are: --> amazon-ebs: AMIs were created: us-east-1: ami-012345abcdef
I need to get that AMI ID to the next step in the pipeline. So I’ve tried changing the script command to the following:
- /bin/packer build webservers/amazonlinux.json | tee packer.log - /bin/packer build webservers/amazonlinux.json > packer.log
Neither one works! When I redirect the output, I stop seeing the logs in the Jobs output like you would expect, it creates the packer.log file, but it doesn’t actually write the output to the file. It’s empty.
If I launch this same docker container locally and do the exact same steps, it works as expected. What are the gitlab runners doing differently that’s making my output redirection not work?
As an additional question, is there a better way to do this? I’m new to gitlab-ci so I don’t know all the tricks. What’s the easiest way to get command output sent as an artifact to the next step?