Windows system support library for jenkins pipeline.
The main intent of this library is to help a configuration management team to manage windows environments easly without worring about handling the operational systems integrations.
This library is being initialy designed all around the powershell capabilities. So it initialy will only support running on windows based nodes.
This library relies on the jenkins powershell plugin. Your jenkins must have this the plugin installed. To know more about the plugin visit PowerShell Plugin page.
To use this library you must add the library github source on your jenkins. Follow the instructions from this page: Using libraries
To use the library in one job add the line below at the start of your plugin.
@Library('my-library-name') _Note that the library name must be the same added on the jenkins.
If you plan on using the library on your entire Jenkins at the library settings select the Load implicitly option.
Manage windows services on remote machines inside a jenkins pipeline.
Verifies if a windows service is installed on the server
def installed = windowsservice.isInstalled 'localhost', 'wmiApSrv'
//or
def installed = windowsservice.isInstalled('localhost', 'wmiApSrv')Get the current status of a windows service.
def status = windowsservice.getStatus 'localhost', 'wmiApSrv'
//or
def status = windowsservice.getStatus('localhost', 'wmiApSrv')Start a windows service.
windowsservice.start 'localhost', 'wmiApSrv'
//or
windowsservice.start('localhost', 'wmiApSrv')Stop a windows service.
windowsservice.stop 'localhost', 'wmiApSrv'
//or
windowsservice.stop('localhost', 'wmiApSrv')Manage Windows files inside a jenkins pipeline.
filesystem.copy origin, destination
//or
filesystem.copy(fromPath, toPath)Copy file to other folder.
filesystem.copy 'C:\\Default\\file.txt', 'C:\\DefaultCopy'
//or
filesystem.copy('C:\\Default\\file.txt', 'C:\\DefaultCopy')Copy all folder contents to other folder.
filesystem.copy 'C:\\Default', 'C:\\DefaultCopy'
//or
filesystem.copy('C:\\Default', 'C:\\DefaultCopy')Copy all files in the folder according to the extension.
filesystem.copy 'C:\\Default\\*.txt', 'C:\\DefaultCopy'
//or
filesystem.copy('C:\\Default\\*.txt', 'C:\\DefaultCopy')Copy files from remote machine to local directory.
filesystem.copy '\\\\RemoteMachine\\Default\\RemoteFile.txt', 'C:\\Default'
//or
filesystem.copy('\\\\RemoteMachine\\Default\\RemoteFile.txt', 'C:\\Default')Copy files to a remote machine.
filesystem.copy 'C:\\Default\\RemoteFile.txt', '\\\\RemoteMachine\\Default'
//or
filesystem.copy('C:\\Default\\RemoteFile.txt', '\\\\RemoteMachine\\Default')Manage internet services
Start W3svc from remote machine
iis.start 'RemoteMachine'
//or with debug param
iis.start debug: true, 'RemoteMachine'Stop W3svc from remote machine
iis.stop 'RemoteMachine'
//or with debug param
iis.stop debug: true, 'RemoteMachine'Restart W3svc from remote machine
iis.stop 'RemoteMachine'
//or with debug param
iis.stop debug: true, 'RemoteMachine'Start Aplication Pool from remote machine
iis.startAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.startAppPool debug: true, 'AppPoolName','RemoteMachine'Stop Aplication Pool from remote machine
iis.stopAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.stopAppPool debug: true, 'AppPoolName','RemoteMachine'Restart Aplication Pool from remote machine
iis.stopAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.stopAppPool debug: true, 'AppPoolName','RemoteMachine'Verify if an application pool exist
iis.appPoolExist 'AppPoolName','RemoteMachine'
//or with debug param
iis.appPoolExist debug: true, 'AppPoolName','RemoteMachine'Verify if an application pool state
iis.getAppPoolState 'AppPoolName','RemoteMachine'
//or with debug param
iis.getAppPoolState debug: true, 'AppPoolName','RemoteMachine'Create a new aplication pool
iis.newAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.newAppPool debug: true, 'AppPoolName','RemoteMachine'Remove an aplication pool
iis.removeAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.removeAppPool debug: true, 'AppPoolName','RemoteMachine'Start Web Site from remote machine
iis.startWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.startWebSite debug: true, 'WebSiteName','RemoteMachine'Stop Web Site from remote machine
iis.stopWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.stopWebSite debug: true, 'WebSiteName','RemoteMachine'Create a new Web Site on a remote machine
iis.newWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.newWebSite debug: true, 'WebSiteName','RemoteMachine'Remove a new Web Site from a remote machine
iis.removeWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.removeWebSite debug: true, 'WebSiteName','RemoteMachine'Verify WebSite state
iis.getWebSiteState 'WebSiteName','RemoteMachine'
//or with debug param
iis.getWebSiteState debug: true, 'WebSiteName','RemoteMachine'Note that the "\" bar is an escape character, so it should be duplicated.
To help debugging possible problems with the script we offer a debug parameter. All the commands accept this paramenter.
See the example below on how to use the debug parameter.
filesystem.copy debug:true, 'C:\\Default\\file.txt', 'C:\\DefaultCopy'
//or
filesystem.copy('C:\\Default\\file.txt', 'C:\\DefaultCopy', debug:true)windowsservice.start debug:true, 'localhost', 'wmiApSrv'
//or
windowsservice.start('localhost', 'wmiApSrv', debug:true)The debug parameter may increase the number of lines on the Jenkins output.
- Start
- Stop
- Check if exists
- Uninstall
- Install
- Manage files and folders in the windows node
- Manage files and folders on a remote windows host
- Copy files from the windows node to a windows remote machine
- Copy artifacts from a job to a windows remote machine <<<<<<< HEAD
- Start IIS
- Stop IIS
- Restart IIS
- Start application pool
- Stop application pool
- Create web site
- Remove web site =======
- Start IIS
- Stop IIS
- Restart IIS
- Start application pool
- Stop application pool
- Create web site
- Remove web site
feature/iis_management
- Edit web site
- Create application pool
- Remove application pool
- Edit application pool
Since the library is executed on the context of the jenkins windows service node, the user running the server must have the correct rights to execute the actions on the remote machine. On a domain based network use a domain user to run the jenkins windows service and give this user the needed access on the managed hosts. If you are not in a domain based network just create a user with the same username and password on the managed machines and give the rights needed access to this user.