In the previous article, Creating Clone of Virtual Machine from PowerShell, we created template to use for cloning images. In this article, we are going to configure Jenkins, so that it can create that automatically as a build or part of a build pipeline.
Installing necessary plugins
The plugin required to execute PowerShell scripts is called PowerShell plugin and you can add it by selecting the Manage Jenkins / Manage Plugins menu from the main Jenkins page.
Configuring the build
Go to the main page of Jenkins and select New Item. Select a name for the configuration and click Freestyle project and OK to create the project.
General
The values for the parameters are from the previous article, don’t forget to replace them with your own if you changed any of them. Check This project is parameterized and enter the following parameters:
Choice Parameter |
|
Name |
TEMPLATE |
Choices |
ate-windows-base |
String Parameter |
|
Name |
IMAGE |
Default Value |
<Left Empty> |
String Parameter |
|
Name |
TEMPLATE_DIRECTORY |
Default Value |
D:\ate\images |
String Parameter |
|
Name |
IMAGE_DIRECTORY |
Default Value |
D:\working-images |
Build
Select Windows PowerShell and in the Command section insert the PowerShell script in the block below.
After saving the configuration, executing the build with parameters will create an image from the template in Hyper-V. One final note, the script is to be executed on the Hyper-V host, also running Jenkins.
You can connect with me on LinkedIn, Twitter or you can register on the blog. Share if you found this article useful or know somebody who would benefit from reading it.
No comments yet.