Auto-hide prebuild logs on workspace start

When executing tasks as a prebuild (this includes init tasks), the logs are saved to /workspace/.gitpod and printed to the terminal once you start the workspace:

.gitpod.yml for reference (I removed the list of extensions and a bunch of comments to shorten this post):

tasks:
  - init: docker pull $(cat .vscode/settings.json | python3 -c "import json, sys; print(json.load(sys.stdin)['vorlage-latex.buildcontainer'])") && exit

github:
  prebuilds:
    master: true
    branches: true
    pullRequests: true
    pullRequestsFromForks: true
    addCheck: true
    addComment: false
    addBadge: true
    addLabel: false

Is there an easy way to prevent printing the prebuild logs or close the terminal right away? The prebuild command in the repo in my screenshot just pulls a single docker image because that’s going to be needed later anyway. There’s really nothing too interesting about pulling a docker image which anyone should have to look at (hence the && exit at the end of the command)

Appending && exit only closes the terminal when no prebuild was run (i.e. when the init command was launched together with the workspace and hasn’t completed yet after the workspace is opened)

Can I shomehow achieve the same when loading a prebuilt workspace?

If you move the exit to the command lifecycle, it will close the bash and with it the terminal.
I mean something like this:

tasks:
  - init: docker pull $(cat .vscode/settings.json | python3 -c "import json, sys; print(json.load(sys.stdin)['vorlage-latex.buildcontainer'])")
    command: exit

2 Likes

Wow, I was so focussed on closing the terminal immediately that I didn’t even think about putting the exit somewhere else. Thank you!

Just one minor thing that probably isn’t gitpod’s fault: Although the task-specific terminal closes after pulling the image, when I launch the workspace (from a prebuilt image), there’s still a “regular” terminal open at the bottom.

I don’t mind the terminal itself, I just didn’t want to have it cluttered by log output. So thanks again :smiley:

I think we generally start one terminal if non exists.

@svenefftinge
I’m exiting the prebuild terminal as well and am also seeing a 2nd terminal that remains open. It isn’t using the .bashrc which I updated in the prebuild and thus is a hang up for the developer experience of my workspace.

I need to modify .bashrc in the prebuild because the modification depends on the dependencies of the repository cloned into the workspace.

Any recommendations as to how to handle this situation?

Not sure if you’re still looking into this, but I was able to overcome this issue by running something like this:

command: ./.gitpod/set_env.sh && source ~/.bashrc && /* Do stuff that requires updated env vars */