Is there an alternative to setting up the whole project workspace in a Jenkinsfile
Using Docker with Jenkins in a situation like this is a great way to 


Keep Jenkins worker slave nodes clean (so you don't have to build or install anything on them)
Have all dependencies and environment in an easily manageable artifact (in this case, a docker image is the snapshot of the exact OS, filesystem, env and dependencies) 
Vendor / keep copies of dependencies at a certain point in time (Example: You don't want to update at the same rate as the dependency)


If you have some kind of artifact management system (Example: Nexus) you can store your docker images in the artifact management system, and then pull them into Jenkins, and create a running container that has your repository in it. From there you can build project run tests inside the docker image. Just be sure you remember to move/copy all test results and built artifacts out of the docker container if you need them or use them later. 

If you need more details or specifics please edit your question and I will edit my answer accordingly.