0

Two part question:

  1. Is my attempted use of gitpod prebuild correct?
  2. How do test my changes to .gitpod.yml - when do I expect steps to run, what output should I expect to see?

My plan is to have a couple of branches in my git repository, colleagues working on a couple of problems. I want to set up their initial environments. I'm aware that some things need to be done in the docker image and some things can be specified in .gitpod.yml - focus here is on what I can do in prebuild.

So I create a branch and in it I update my basic .gitpod.yml

ports:
  - port: 3000
github:
  prebuilds:
    # enable for the default branch (defaults to true)
    master: true
    # enable for all branches in this repo (defaults to false)
    branches: true
    # enable for pull requests coming from this repo (defaults to true)
    pullRequests: true
    # enable for pull requests coming from forks (defaults to false)
    pullRequestsFromForks: false
    # add a check to pull requests (defaults to true)
    addCheck: true
    # add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
    addComment: false
    # add a "Review in Gitpod" button to the pull request's description (defaults to false)
    addBadge: true

I believe that I have enabled gitpod builds:

gitpod extension

I then attempt to add a trivial bit of work to the prebuilds (eventually I want to do something more useful, such as start node express in one pane).

github:
  prebuilds:
     master: true
     # etc ... lines elided
     tasks:
     - name: "Lefty"
       command: echo 'left'
     - name: "Dexter"
       command: echo 'right'
       openMode: split-right

I check that change in and push to the branch. My expectation is that I would at some point see a split terminal window with some echoed text.

I'm not clear on the workspace life-cycle as to when this should happen. I have tried this sequence:

  1. Push updated .gitpod.yml
  2. Close workspace, delete workspace
  3. Create new workspace from branch URL

This brings up a new workspace with the updated .gitpod.yml but I see no evidence of the prebuild. I'd welcome re-education ;-)

djna
  • 54,992
  • 14
  • 74
  • 117

1 Answers1

1

I had misunderstood the .gitpod.yml syntax, the tasks section should be at the top level rather than, as I had it, under prebuilds.

github:
   prebuilds:
     master: true
     # etc ... lines elided
tasks:
    - name: "Lefty"
      before: |
          echo "In $(pwd)"
      init: |
          echo "Could npm install here"
      command: |
          echo 'left'
    - name: "Dexter"
      command: |
          echo 'right'
      openMode: split-right

I checked that restructured .gitpod.yml file into git, started a new workspace and saw the scripts run in split windows.

The take-away idea is that the tasks stanza is independent of the particular git you are using; in my case the github stanza determines when the before, init and command scripts are run.

djna
  • 54,992
  • 14
  • 74
  • 117
  • Yeah, you got that right. You can always take ref from: https://www.gitpod.io/docs/config-gitpod-file – AXON Jul 08 '22 at 13:05