Usage Examples
Create a Service Account to access Jenkins with cli
Step 1: Create a service user account in the StackTrack Identity Service admin console. Step 2: Log in to Jenkins with the service account and create an API Token. Step 3: Create a role in Jenkins for the service account with the least privileges principle. Manage Jenkins -Manage Roles. Step 4: Assign the new role created in Step 3 to the service account via the assign role menu in Jenkins. Assign Role Link. Step 5: Execute the Jenkins cli with the API Token and service user login inFeaturedClean Jenkins Workspace
Cleaning a workspace is an important housekeeping activity for your pipelines because we rarely overprovision storage so there is usually only enough space on an agent for a few builds. If the intention is that you want to resuse agents then we advise you to perform some housekeeping activities in your pipelines. To do this we leverage the post function in the Jenkins pipeline to execute tasks at the end of a pipeline. The post pipeline supports properties to enable you to run various activitiesFeaturedJenkins Pipeline Troubleshooting
Pipeline Steps Even though Pipeline provides a stage view and details of the complete build, it is very beneficial to know the troubleshooting issues using Pipeline steps. Pipeline steps can view directly by clicking on Pipeline steps menu bar inside the build (or) using any of the below direct links. The Pipeline Steps screen is also the way to get tFeaturedMultiBranch Pipeline
Multibranch Pipeline is one of the Pipeline project type in Jenkins 2.0 with Automated building and configuration capabilities. Dependent Plugins: Branch API (required) Pipeline: API (required) Pipeline: Job (required) Pipeline: SCM Step (required) Pipeline: Step API (required) Pipeline: Supporting APIs (required) Pipeline: Groovy (required) Folders (required) SCM API (required) Script Security (required) Structs (required) JAXB (implied) Features: This ProjectPopularClean up MultiBranch Pipelines that have been disabled
For multi-branch pipelines, when the feature branch (or) pull request is closed in git. These are marked as disabled by multi-branch pipeline automatically, but Jenkins wont delete the job history. This script will check and delete the jobs and builds of disabled jobs.Few readersSetup External SSH Agents Delete Edit article
Setup External SSH Agents Important Note: There is no need to install Jenkins on the agent machine. 1: On your Jenkins controller go to Manage Jenkins Manage Nodes & Clouds. New Node: Enter node name Configure the settings are described in below screenshots. SigFew readersBuild your Ruby with our RubyGem mirror
Add this to your Gemfile Or if you want to pull from multiple sources do this If you have any questions on need support let us know.Few readersCan't end trigger check
This issue relates the the Github Pull Request Builder plugin. The plugin is seeking adoption and also contains duplicate functionality in the more recent Github Branch Source plugin. When using this plugin unfortunately an error occurs because the connections to Github are cached on the controller. However once in a while, you might notice this issue in your console logs. Please read on for a resolution.Few readersDeclarative pipelines or Scripted Pipelines
Scripted syntax is an initial way that Pipeline-as-code have been done in Jenkins. Its Imperative syntax which means it is based on defining the logic and to program the flow in the pipeline script itself. It is also more dependent on the Groovy constructs and language.Few readersManaging Script Security
Controlling Script Security Script security plugin provides increased flexibility to execute commands and do processing comes increased importance of being able to control security on the scripts that developer executes Script Checking When a Jenkins administrator creates a script or includes a script in a configuration and saves it, the script is automatically approved and added to an approved list. Those scripts in the approved list can be run by anyone. If a non-administrator trieFew readersUser Management
Searching For Users If you need to search a specific user, click on Users in the left menu bar. This menu option brings you to the user list page. In the search box you can type in a full name, last name, or email address you want to search for in the user database. The query will bring up all users that match your criteria. The View all users button will list every user in the system. This will search users created viaFew readersSetup external JNLP Agents
Important Note: There is no need to install Jenkins on the agent machine. If you knew that then you know in Jenkins we call these Permanent Agents. 1: On your master machine go to Manage Jenkins Manage Nodes & Clouds . New Node: Enter the node name Configure the settings are described in below screenshots. Significance of each field is dFew readers
Tutorials
Jenkins Shared Library Tutorial
Jenkins Shared Library Tutorial Learn to build reusable, testable pipeline code that follows the DRY principle A comprehensive, production-ready guide to Jenkins Shared Libraries with working examples, tests, and Job DSL integration. 📚 Documentation Getting Started ← Start here Advanced Guide - Testing, Job DSL, advancedFeaturedJenkins Shared Library Tutorial - Advanced Guide
Jenkins Shared Library - Advanced Guide Prerequisites: Complete the main tutorial first to understand the basics. This guide covers advanced topics for mastering Jenkins Shared Libraries. Table of Contents (https://github.com/Servana/jenkins-shared-library-tutorial/blFeaturedJenkins Shared Libraries Tutorial - Reference
Complete examples, troubleshooting, and API reference. Table of Contents Reference - Table of Contents Team-Based Job DSL Examples Complete Pipeline Examples (https://github.com/Servana/jenkins-shared-library-tutorial/blob/main/docs/reference.mdcomplete-piFeatured
Jenkins Controller, Nodes, Agents, and Executors
TABLE OF CONTENTS Controller Node Agent Executors Managed Service Controller Jenkins Controller is the primary controlling system and heart for a Jenkins instance. The controller allows managing complete configuration, plugins and jobs. It is not recommended to run heavyweight tasks on Jenkins controller. Also running jobs on the masPopularRestricting access in Jenkins
The scenario for this document is to provide 2 users, one in each team with access to an isolated sandbox environment on a Jenkins master. Do you want to be able to manage granular access to areas in Jenkins that a user has permissions to view. To do this with Jenkins isn't straight forward but we this this pattern works really well. restrict access to credentials prevent users from being able to access repositories they don't have access to in your source code manager provide adequate pFew readersCreate Jenkins Shared Libraries
Jenkins - Shared Libraries Code reuse is the most essential technic for CI/CD platform. Jenkins fulfils this feature with shared pipeline libraries. Shared libraries are composed of code with simple/complex logic stored in a source code repository that is automatically downloaded within the pipeline and available as pipeline functions. It encourages standard ways to invoke common functionality, create a building block for more complex operations. (Untrusted Vs Trusted) Shared LibrariesFew readers