Can a non background step wait until the preceding backgrounds steps are completed?

I have a config.yml looks like:

version: 2.0
      TZ: "Europe/Berlin"
      BUNDLE_PATH: vendor/bundle
      - image: circleci/ruby:2.3-node-browsers
          DATABASE_USER: ubuntu
          NPM_CONFIG_PREFIX: ~/.npm-global
      - image: circleci/postgres:9.6-alpine-postgis
          POSTGRES_USER: ubuntu
      - checkout
      # .. some other steps
      - run:
          name: Start Webpack server
          working_directory: frontend
          background: true
          command: sysconfcpus -n 1 npm start
      - run:
          name: Start Rails server
          working_directory: backend/ruby
          background: true
          command: RAILS_ENV=development bin/rails s -p 3000 -b
      - run:
          name: Install E2E gems
          working_directory: frontend_end_to_end
            BUNDLE_JOBS: 4
            BUNDLE_RETRY: 3
          command: |
            wget --waitretry=5 --retry-connrefused -v
            bundle check || bundle install
            bundle exec rspec ./spec

Can I use up the when option to tell the step Install E2E gems to start when the preceding 2 steps succeeded?

Yes. Write a file at the end of your background tasks, and then finally use a Bash loop to detect when all the files have been written.

The file writing could be as easy as:

sysconfcpus -n 1 npm start && touch /tmp/finished1

(and the same for the others, but use finished2, finished3, etc.)

Thanks for your idea. When to use when option then?

If you mean the 2.1 feature of conditional steps, you don’t need that here. I guess that would be useful if, for example, you wanted to run optional test/build steps based on the contents of a Git tag.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.