When running Jenkins jobs that are kicking off Terraform scripts, the workspaces are initialised each time. Is there a way to preserve the downloaded plugins when Terraform initialises. Would the -plugin-dir option be the best?
Asked
Active
Viewed 113 times
0
-
I haven't used Jenkins much - does it have the option to cache results? If so, you could try that. Otherwise, you could have a local network share that holds the plugins, and pull them from that as the first stage of the Jenkins job – lxop Oct 11 '20 at 21:00
-
You need to expand your question to cover how your Terraform jobs are ran in Jenkins and anything you've tried/problems you've ran in for this to be properly answerable. That said, [this answer](https://stackoverflow.com/a/50944611/2291321) explains how to create a Dockerfile with all of the Terraform plugins already downloaded at the version required which is one option to solve this. – ydaetskcoR Oct 12 '20 at 12:56
-
Yeah, unless you won't clear up the Jenkins workspaces often, `-plugin-dir` works perfectly fine. Then, you can have a Cron refreshing the plugins in the background on the Jenkins with new mirror provider functionality. Check this link https://www.terraform.io/docs/commands/providers/mirror.html – harshavmb Oct 12 '20 at 19:09