liveBook · Manning

Jenkins

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

Jenkins is an open-source automation server that orchestrates software delivery and other automated jobs.

Jenkins is an open-source automation server for managing scheduled scripts and other jobs through a centralized web interface. Role-based access and credential storage let operators authorize execution without granting users direct permissions on target systems. section 3.2.4

A practical Jenkins automation design accounts for:

  • Execution location: PowerShell runs on the Jenkins server unless the job uses PowerShell remoting or a Jenkins node. section 3.2.4
  • Parameter passing: replace script parameters with values read from lowercase Jenkins environment variables. section 3.2.4
  • Secret handling: bind Jenkins credentials to environment variables, then reconstruct SecureString or PSCredential values when PowerShell requires them. section 4.4.2
  • Operational control: use centralized credential stores, graphical management, usage logging, and role-based access. section 3.2.4 section 4.4.2

SQL health check

A Jenkins job binds SQL credentials, a SQL instance, and SendGrid values to environment variables. PowerShell converts the username and password back into a PSCredential, invokes a database diagnostic query, identifies databases whose recovery model is not SIMPLE, and uses the notification bindings when a check fails. section 4.4.2

$LogPath = $env:logpath
$ZipPath = $env:zippath
$ZipPrefix = $env:zipprefix
$NumberOfDays = $env:numberofdays

Use the environment-variable pattern to adapt an existing parameterized PowerShell script for Jenkins execution. section 3.2.4

Table 4.2 Secrets required for the SQL health check script using Jenkins (view table figure)

ID

Kind

Value

TestSQL

Secret text

<Your server name>\SQLEXPRESS *

TestSQLCredential

Username with password

Username* : sqlhealth Password* : P@55w9rd

SendGrid

Secret text

Your email address

SendGridKey

Username with password

When using SendGrid, the username will be apikey, and the password will be your API key.

* These are the default values if you used the setup scripts provided in the GitHub repo.

Review the credential objects required for SQL and SendGrid automation. section 4.4.2

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Explains job execution, environment-variable adaptation, remote-run constraints, and credential reconstruction through a SQL health-check implementation.
Examples
Demonstrates scheduled disk-space and log-cleanup scripts plus a SQL health check that can notify through SendGrid.
What it assumes
Assumes working PowerShell scripts and a Jenkins development instance; teaches Jenkins-specific parameter and credential integration.
What you can do after
Operate/configure Jenkins jobs that run PowerShell scripts and securely supply their parameters and credentials.
How it connects
Connects Jenkins with PowerShell, continuous integration, PowerShell remoting, Jenkins nodes, environment variables, credentials, SecureString, and PSCredential.

Also explained in

Compare how 2 books explain Jenkins →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.