public function buildPipeline(array $queue)
    {
        // First we'll build the queue
        $pipeline = new Pipeline();

        // Get the connections to execute the tasks on
        /** @var ConnectionInterface[] $connections */
        $connections = $this->connections->getActiveConnections();
        foreach ($connections as $connection) {
            $connectionKey = $connection->getConnectionKey();
            $stages = $this->getStages($connectionKey);

            // Add job to pipeline
            foreach ($stages as $stage) {
                $connectionKey->stage = $stage;

                $pipeline[] = new Job([
                    'connectionKey' => clone $connectionKey,
                    'queue' => $queue,
                ]);
            }
        }

        return $pipeline;
    }