Run command on only one node when using parallelism


#1

When using parallelism there are 2 commands I need to run as part of the entire test suite but they only need to be run on 1 node rather than all of them. I’ve managed to achieve this by dropping down to bash conditionals but I’m wondering if there is a better way to achieve the same thing? One of the downsides of my approach is that the commands appear in the web interface as a step even though nothing was run on the node.

  - run:
      name: rubocop
      command: |
        if [ $CIRCLE_NODE_TOTAL -gt 1 ]
        then
          case $CIRCLE_NODE_INDEX in
          0) bundle exec rubocop ;;
          esac
        else
          bundle exec rubocop
        fi

  - run:
      name: factory_girl:lint
      command: |
        if [ $CIRCLE_NODE_TOTAL -gt 1 ]
        then
          case $CIRCLE_NODE_INDEX in
          1) bundle exec rake factory_girl:lint ;;
          esac
        else
          bundle exec rake factory_girl:lint
        fi

#2

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