Skip to content

Kalgros20/jenkins-windows-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

144 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jenkins-windows-library

Windows system support library for jenkins pipeline.

Intent

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.

How to use it

Dependencies

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.

Installing

To use this library you must add the library github source on your jenkins. Follow the instructions from this page: Using libraries

Using

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.

Features

Windows services

Manage windows services on remote machines inside a jenkins pipeline.

isInstalled

Verifies if a windows service is installed on the server

def installed = windowsservice.isInstalled 'localhost', 'wmiApSrv'
//or
def installed = windowsservice.isInstalled('localhost', 'wmiApSrv')

getStatus

Get the current status of a windows service.

def status = windowsservice.getStatus 'localhost', 'wmiApSrv'
//or
def status = windowsservice.getStatus('localhost', 'wmiApSrv')

start

Start a windows service.

windowsservice.start 'localhost', 'wmiApSrv'
//or
windowsservice.start('localhost', 'wmiApSrv')

stop

Stop a windows service.

windowsservice.stop 'localhost', 'wmiApSrv'
//or
windowsservice.stop('localhost', 'wmiApSrv')

File System

Manage Windows files inside a jenkins pipeline.

copy

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')

IIS

Manage internet services

Start W3svc

Start W3svc from remote machine

iis.start 'RemoteMachine'
//or with debug param
iis.start debug: true, 'RemoteMachine'

Stop W3svc

Stop W3svc from remote machine

iis.stop 'RemoteMachine'
//or with debug param
iis.stop debug: true, 'RemoteMachine'

Restart W3svc

Restart W3svc from remote machine

iis.stop 'RemoteMachine'
//or with debug param
iis.stop debug: true, 'RemoteMachine'

Start AplicationPool

Start Aplication Pool from remote machine

iis.startAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.startAppPool debug: true, 'AppPoolName','RemoteMachine'

Stop AplicationPool

Stop Aplication Pool from remote machine

iis.stopAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.stopAppPool debug: true, 'AppPoolName','RemoteMachine'

Restart AplicationPool

Restart Aplication Pool from remote machine

iis.stopAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.stopAppPool debug: true, 'AppPoolName','RemoteMachine'

AplicationPool Exist

Verify if an application pool exist

iis.appPoolExist 'AppPoolName','RemoteMachine'
//or with debug param
iis.appPoolExist debug: true, 'AppPoolName','RemoteMachine'

AplicationPool State

Verify if an application pool state

iis.getAppPoolState 'AppPoolName','RemoteMachine'
//or with debug param
iis.getAppPoolState debug: true, 'AppPoolName','RemoteMachine'

New AplicationPool

Create a new aplication pool

iis.newAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.newAppPool debug: true, 'AppPoolName','RemoteMachine'

Remove AplicationPool

Remove an aplication pool

iis.removeAppPool 'AppPoolName','RemoteMachine'
//or with debug param
iis.removeAppPool debug: true, 'AppPoolName','RemoteMachine'

Start WebSite

Start Web Site from remote machine

iis.startWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.startWebSite debug: true, 'WebSiteName','RemoteMachine'

Stop WebSite

Stop Web Site from remote machine

iis.stopWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.stopWebSite debug: true, 'WebSiteName','RemoteMachine'

New WebSite

Create a new Web Site on a remote machine

iis.newWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.newWebSite debug: true, 'WebSiteName','RemoteMachine'

Remove WebSite

Remove a new Web Site from a remote machine

iis.removeWebSite 'WebSiteName','RemoteMachine'
//or with debug param
iis.removeWebSite debug: true, 'WebSiteName','RemoteMachine'

WebSite State

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.

Debuging

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.

Roadmap

Windows services features

  • Start
  • Stop
  • Check if exists
  • Uninstall
  • Install

File system features

  • 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

Internet Information Services (IIS) features

  • Start IIS
  • Stop IIS
  • Restart IIS
  • Start application pool
  • Stop application pool
  • Create web site
  • Remove web site =======

Internet Information Services (IIS)

  • 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

Access control

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages