I am trying to create a custom task to create our project in our continuous integration environment. This is a set of line steps.
- Send a chat start message
- Compile templates
- Running npm tests
- Run jshint
- Compile
- Create an application artifact
- Upload artifact to our deployment server
- Running tests
- Send test results to our deployment server
- Send assembly results message to chat
Please note that step 10 should be performed if any steps are not performed, and the message should be configured depending on which step failed, for example. if step 5 failed, he should say: “Compilation error”, if step 8 failed, he should say how many tests were completed and how many failed.
To make something interesting, this is an assembly of several projects, so when running tests and publishing the results, it should run all the tests and publish the aggregated results.
To make things even more interesting, the npm, jshint and artifact tests really make sense in the webapp subproject, where Javascript lives, and the web server.
I looked at sbt-release for inspiration, but I was involved in how to take the value created by one task and use it in the next, how to run tasks together and get produced values (I see a method in Extracted to run aggregated tasks, but it does not give produced values) how to run tasks in a subproject and get the produced value, and how to perform error handling.
So far I have tried two approaches
npmTest.result.value match { case Inc(inc) => println(inc) case Value(res) => Def.taskDyn { (executeTests in Test).result.value match { case Inc(inc) => println(inc) case Value(res) => println(res) } }
The problem with the above is that executeTests always runs, even if npmTest fails. And not one of println is running.
npmTest.result. flatMap {- case Inc(inc) => task { println(inc) } case Value(res) =>- (executeTests in Test).result. flatMap { case Inc(inc) => task { println(inc) } case Value(res) => task { println(res) } } }
This does not compile because (executeTasks in Test)... creates the value Initialize[Task[Unit]] , and << 29> is required.
Is there any way to accomplish this with sbt?