
Master Jenkins pipeline as code from a to z with practical guidance on syntax and capabilities, designed for beginners and intermediate learners who know Jenkins and basic Groovy.
Explore Jenkins pipeline syntax with an interactive spreadsheet that navigates decorative syntax (pipeline) and scripted syntax (node). Prepare for a hello world pipeline in the next lesson.
Create a hello world pipeline script in Jenkins with agents and stages. Define a steps section and an echo step to print hello world, and view the console output.
Explore how Jenkins runs pipelines on any available agent, none, or a labeled agent, and how custom workspaces affect execution on specific slaves.
Explore how the script step extends declarative Jenkins pipelines using Groovy to perform complex flows, including if-else logic, sleep, and echo printing.
Apply retry and timeout steps in Jenkins pipelines using the Workflow Basic Steps plugin, including nested configurations with sleep and error steps.
Explore the tool section in Jenkins pipelines, configuring preinstalled tools via global tools configuration in managed Jenkins, then run a pipeline shell step to display Maven version and Maven home.
Explore the timeout option in the pipeline options directive to delay before steps and demonstrate how a one-second timeout with a two-second sleep times out the stage.
Learn to timestamp console output by applying timestamp options at the stage and pipeline levels, showing timestamps for build and for every echo line.
Use a timestamp block inside the stage's steps as an alternative to placing timestamps in the options, since pipeline or options level timestamps trigger syntax errors.
Demonstrates skip default checkout at stage and pipeline options to control repository checkout in a Jenkins declarative pipeline. Observe how workspace contents change with and without the option.
Explore the environment directive at pipeline and stage levels, access environment variables and credentials by ID, and observe stage precedence and credential masking in scripts.
Demonstrate how the building tag condition limits stage execution to tagged commits, and how tag patterns in a Jenkins multi-branch pipeline enable selective builds from GitHub tags such as 1.0.
Explore how the changelog condition gates a pipeline stage by requiring commit messages to match a regular expression in a multi-branch Jenkins pipeline.
Learn how the change request condition gates pipeline stages to run only on pull requests in GitHub, demonstrated with a multi-branch Jenkins pipeline on master and dev branches.
Explore the change set condition in Jenkins pipeline as code by filtering stages to run only when committed JavaScript files match a regular expression, with case sensitivity options demonstrated.
Learn how the before agent setting controls when directive evaluation occurs in a Jenkins pipeline, choosing between remote agent evaluation and before entering the stage, with a slave one example.
Describe the input step in a stage, pausing after options are applied and continuing only after approval, exposing input parameters as environment variables for the rest of the stage.
Explore the post section in Jenkins pipelines, with post condition blocks like success, failure, always, and cleanup, applicable at pipeline and stage levels, using the script block and currentBuild.
Learn how the BuildDiscarder option in the pipeline options controls how many Jenkins builds to keep and review how the console logs reflect the retained history.
Explore the disable concurrent builds option in the options directive to prevent concurrent access to shared resources, demonstrated by one job waiting for another to finish.
Learn how the skip stages after unstable option directive in Jenkins pipeline as code skips downstream stages when a build becomes unstable, with a build and deploy example.
Learn how the checkout to subdirectory option in Jenkins directs code to a subfolder in the workspace, shown with a GitHub repository containing a Jenkins file and a text file.
Explore how the new container per stage option lets each pipeline stage run a fresh container with distinct container ids during build and deploy, using a pipeline-level image.
Explore pipeline level parameters, including string, boolean, choice, text, password, file, and credentials inputs; learn how defaults versus prompts use the params object to drive parameterized builds.
Learn how to configure Jenkins pipeline triggers with poll SCM, using cron string formats to poll a repository, checkout code, and detect changes from GitHub.
Explore how the upstream trigger in Jenkins activates the current job when upstream jobs finish with specified status, such as unstable or failure, and how status changes affect downstream builds.
Demonstrate the arcs parameter to pass docker run arguments and set an environment variable with -e in a Jenkins job, then echo and verify the some env value in build.
Demonstrate the always pull parameter by running a Jenkins job that performs a docker pull from library Maven and checks the image is up to date.
Configure a custom workspace in Jenkins with the custom workspace parameter, set it to lib/jenkins/workspace, custom workspace, and ensure Jenkins has access before running the job so Docker uses it.
Configure a Jenkins pipeline to pull images from a private docker registry using a registry URL and credentials ID, create credentials in Jenkins, and verify with a print env step.
Utilize the label parameter to run a Jenkins pipeline stage on a specific node, demonstrated by executing a Maven image on slave one and printing Maven version.
Explore how the reused node parameter directs container execution across agents and stages, with true or false settings showing build on slave two and deploy on slave one.
Master the Docker file parameter of agent to run a container for a Jenkins pipeline stage, including workspace polling and building from Ubuntu latest with a GitHub Docker file.
Shows how to use the Dockerfile dir option to locate a Dockerfile in a subdirectory, build Ubuntu latest image, check out from GitHub, run the container, and print OS details.
Explore how to use additional build args in a Dockerfile within a Jenkins pipeline, tag the image, checkout from a GitHub repo, and print operating system details.
Utilize the custom workspace option of the Docker file parameter by pointing to a subdirectory of the build workspace to build and run a container with Jenkins.
Explore advanced Groovy usage in Jenkins pipeline as code by executing Groovy outside the pipeline script, calling a print name function via script directive and echo.
Learn how to import a library from the source folder, instantiate a calculator object, and call its Add function within a script block, printing results with a print line.
Explore using static methods in shared libraries for Jenkins pipelines. Learn to import static methods and call them directly or dynamically via a qualified name with the validator utils example.
Learn how closures enable custom steps in Groovy Jenkins pipelines by building an execute in script step that runs a closure block and prints environment variables via a shared library.
Import third party java libraries from Maven Central into a pipeline script using grape's ad grab annotation to load the Apache Commons StringUtils, then uppercase text in Groovy.
Learn to load non groovy resources from a Jenkins shared library by storing a json file in the resources directory, importing the library with ad library syntax, and echoing it.
Import the shared library, call the custom step with a string parameter to select and run the corresponding pipeline script (build, deploy, or do nothing) in Jenkins.
Explore scripted pipeline syntax using Groovy, including node blocks and stages, with examples showing execution on the master and slave nodes and the differences from declarative pipelines.
Set a Docker custom workspace in scripted pipeline using the workspace step; run a Jenkins job with a Maven image to print the Maven version via the Insight method.
Load a Docker image from a registry URL in a scripted Jenkins pipeline, authenticate with credentials id, pull and run the image, and print environment variables.
Discover how to locate a Dockerfile in a subdirectory within scripted pipelines, build an image from the Ubuntu latest base, and print OS details in a Jenkins job.
Set a custom workspace for dockerfile builds in scripted pipelines, using a single ubuntu latest dockerfile, checkout, build with a name:tag, then print details.
Use timestamps in scripted pipeline code to timestamp build and deploy stages, then place the time stamps block inside a stage to observe stage-specific timestamps.
Bind username and password in Jenkins scripted pipelines using the with credentials function from the credentials binding plugin, and observe masking in the console.
Implement the when directive in a scripted Jenkins pipeline by creating a job, using withEnv to declare deploy environment variables, and test when expressions against env variables and groovy equivalents.
Demonstrates implementing the When directive's branch condition in a scripted Jenkins pipeline, using env.BRANCH_NAME to run build master on master and build death on dev, via a multi-branch GitHub project.
Learn to implement building tag and tag conditions of the when directive. See how tag name environment variable selects tag builds versus branch builds for release 1.0 and 2.0.
Explore implementing the change log condition of the when directive in scripted pipeline code using a git change set, regex checks, and Jenkins stages.
Demonstrate the change request condition of the when directive in scripted pipelines using a GitHub repo and Jenkins file. Create a pull request titled when PR and verify environment variables.
Learn to implement the change set condition of the when directive in scripted pipelines using groovy, a GitHub repo, and js file changes to trigger build stages.
Implement the parallel block with a fail fast option in scripted Jenkins pipelines, compare three parallel branches sleeping 10s to sequential execution, and observe stage behavior on the Jenkins page.
Implement input in scripted pipeline code by declaring a user input variable, echoing the selection, and using a timeout block to avoid a stalled build when no input is provided.
Demonstrate implementing the build discarded option in scripted pipeline code by creating a Jenkins job. Observe how the property keeps only one build log for demonstration.
Demonstrates implementing disable concurrent builds in a Jenkins scripted pipeline, configuring properties, and observing builds queue and wait for prior runs versus allowing concurrent executions.
Learn to skip stages after unstable in scripted pipeline code by configuring a two-stage jenkins job and conditionally skipping deploy when the build is unstable.
Set up a Jenkins pipeline with two stages that create a new container per stage using the options directive, printing the Maven version in each stage.
Configure poll scm triggers in Jenkins scripted pipelines. Poll GitHub at configured intervals, check out code, and trigger builds automatically on changes.
Learn to use upstream option in triggers directive of scripted pipeline code to auto-build a Jenkins job when upstream jobs succeed, with unstable, failure, not built, and aborted statuses.
Advance your understanding and application of Jenkins pipeline as code as you complete the course, and share a review or feedback to shape future lectures.
Learn to capture shell output in a variable and its exit status in a Jenkins pipeline. Use scripted syntax with shell steps returning stdout and status, trim to control builds.
Learn how to create and use environment variables in Jenkins pipeline scripts and shell steps, including withEnv blocks, printing variables, and validating scope with mvn version.
Learn how Jenkins pipelines handle Maven integration by configuring settings file path, settings config, and local repo precedence. Adjust Java versions and Maven options, publish artifacts and test results.
Learn to integrate Maven builds with Sonarqube via a Jenkins pipeline, using the mvn sonar plugin, monitor quality gates, and enforce gate results through webhooks.
Learn to trigger downstream jobs from a parent in Jenkins pipelines and pass data via deploy env parameter. Use build step and pipeline syntax to generate scripts.
Explore the lockable resources plugin to enable resource locking among competing builds, using logical resources, labels, and reserved by text in Jenkins.
Demonstrates creating a multi-select checkbox input parameter in a Jenkins pipeline using the extended choice parameter plugin, with scripted pipeline, console output, and delimiter options.
More lectures on their way!
*** Please note that this is NOT a how to set up Jenkins course. This is a course for people who ALREADY knows what jenkins pipelines are used for, want to use it and want to get up to speed with the syntax or learn more about it quickly.***
*** Get latest course updates in the readme when you search for user pipelineascodecourse in github ***
Are you looking to use Jenkins pipeline as code FAST?
"With Pipelines, organisations can define their delivery pipeline through a DSL (Pipeline-as-code). Pipelines, thus, can be versioned, checked into source and easily shared within an organisation. "
"The Pipeline DSL helps you capture complex process requirements through code - thus you can try-catch on deployment failures, loop through deployments, run tests in parallel. It brings the power of a programming language (groovy) to do so. At the same time, the DSL is simple enough to capture simple cases easily without having to touch groovy code. You can capture common patterns in functions and keep them in a global library so that new applications can build on these functions rather than re-invent. "
Source: Cloudbees - Jenkins Pipeline - Software Delivery Made Easy
Jenkins Pipeline as Code allows you to define and automate pipelined job processes with code. Code that can be stored and versioned in a repository which allows you to track changes over time and used by jenkins to run build jobs. If you are already using Jenkins, you should have already heard of pipeline as code but if you have not, this course will help you learn what it is, and also help you to get started quickly with it to make your life as a devops practitioner much easier. This course will help you understand and use both declarative and scripted pipeline scripts and how to use shared libraries for common code across build jobs with realtime demonstrations of the pipeline scripts.