Posts

JENKINS - Build In Variables

 Jenkins provides a variety of built-in environment variables that can be used in your Jenkins Pipelines to access information about the build environment, the build process, and the system. Here is a comprehensive list of the most commonly used built-in environment variables, along with their descriptions: Common Built-in Jenkins Environment Variables BUILD_ID Description : A unique identifier for the current build. It is the same as BUILD_NUMBER . Example : 2024 BUILD_NUMBER Description : The current build number, which is an incrementing integer starting from 1. Example : 42 BUILD_DISPLAY_NAME Description : The display name of the current build, often including the build number. Example : #42 BUILD_TAG Description : A unique identifier for the current build in the format job_name_build_number . Example : jenkins-MyJob-42 BUILD_URL Description : The URL to the build's web page. Example : http://localhost:8080/job/MyJob/42/ JOB_NAME Description : The name of the job being executed...

Jenkins-All

Image
   https://www.youtube.com/watch?v=7KCS70sCoK0&t=843s https://plugins.jenkins.io/ ------------------------------------------------------------------------------------------------------------------------------- Post Job -- some automated script such as sending an email etc on the status of the built whether it is successful or not. Define conditional run of the steps for instance, you want to run the test in development branch build . The current / active branch name in the build is always available in the jenkins file through and environmental that jenkins provides it . BRANCH_NAME /OR env.BRANCH_NAME  check if this is dev branch This part of the buuild will only execute if the current branch is dev. If you only want to build your application when there are code changes. if branch name and code changes are true CODE_CHANGES is the variable that you define yourself globally like below. getGitChanges()  -- This would be a groovy script to check if there is any c...

Declarative Groovy Pipeline

  -- A Sample Declarative Pipeline - Build, test and , build docker image , update GitOps repository pipeline { agent any environment { DOCKER_REGISTRY = "your-docker-registry-url" GITOPS_REPO = "your-gitops-repo-url" GITOPS_BRANCH = "main" } stages { stage('Build and Test') { steps { // Checkout your source code from version control checkout scm // Run tests, build binaries, etc. sh 'make test' } } stage('Build Docker Image') { steps { script { def dockerImageTag = "test-${env.BUILD_NUMBER}" // Build Docker image sh "docker build -t ${DOCKER_REGISTRY}/your-image-name:${dockerImageTag} ." ...