# Running custom bash (test/validation) scripts in parallel

**URL:** <https://discuss.circleci.com/t/running-custom-bash-test-validation-scripts-in-parallel/2946>\
**Category:** Build Environment\
**Tags:** java, parallelism, circle-yml, sbt, scala\
**Created:** [March 25, 2016, 5:21pm UTC](https://discuss.circleci.com/t/running-custom-bash-test-validation-scripts-in-parallel/2946 "2016-03-25T17:21:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcospereira](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/marcospereira/32/2219_2.png) [@marcospereira](https://discuss.circleci.com/u/marcospereira)\
**Post date:** [March 25, 2016, 5:21pm UTC](https://discuss.circleci.com/t/running-custom-bash-test-validation-scripts-in-parallel/2946/1 "2016-03-25T17:21:53Z")

</div>

I’m trying to build Playframework using CircleCI and see if it will behaves more stable than our current CI. Play is a Java/Scala project, using Scala 2.11 and SBT 0.13.11 (which I’ve manually installed as [suggested at the docs](https://circleci.com/docs/language-scala/#using-a-custom-version-of-sbt)).

My doubt is about how to proper use the parallel feature to execute validation (not only tests, but code inspections too) steps in parallel. Here is what I tried until now:

1. Adjust the parallelism to use 4x (Project Settings \> Parallelism)
2. Write my [`circle.yml`](https://github.com/marcospereira/playframework/blob/d045ea47a1d31dde27ff3a149343cb25aa16fc83/circle.yml) file to add the `parallel: true` flag to each command that can execute in parallel
3. Fire a build

Then, instead of executing the validation steps in parallel, Circle executed all the commands 4x (four builds executing all the steps). And then I decided to try like this:

1. Adjust the parallelism to use 1x (Project Settings \> Parallelism) (I was wild guessing that the parallel configuration would be inferred from `circle.yml`).
2. Write my `circle.yml` file to add the `parallel: true` flag to each command that can execute in parallel
3. Fire another build

Still no game. All the commands are executed sequentially, but this time once.

What I was expecting was to have the test/validation commands to be executed in parallel (4x).

ps.: I’m currently configuring the build for my own fork. After a green/parallel build and when everything works as expected, I can go for the official repository.

---

<div class="post-metadata">

**Author:** ![adsteel](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/adsteel/32/2499_2.png) [@adsteel](https://discuss.circleci.com/u/adsteel)\
**Post date:** [April 15, 2016, 7:39pm UTC](https://discuss.circleci.com/t/running-custom-bash-test-validation-scripts-in-parallel/2946/2 "2016-04-15T19:39:05Z")

</div>

Unfortunately it’s not that easy. You have to specify the node index you want to run each script.

```
test:
  override:
    - case $CIRCLE_NODE_INDEX in 0) rake spec ;; 1) npm test ;; esac:
        parallel: true

```

You can see more advanced ways to handle this in the “Using environment variables” section of the parallelization docs. [https://circleci.com/docs/parallel-manual-setup/](https://circleci.com/docs/parallel-manual-setup/)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/running-custom-bash-test-validation-scripts-in-parallel/2946/3 "2018-06-18T11:38:07Z")

</div>


