Skip to main content

Command Palette

Search for a command to run...

Harnessing Post-Build Actions in Jenkins Pipelines

Updated
โ€ข2 min read
Harnessing Post-Build Actions in Jenkins Pipelines
K

"Hello, I'm Kiran Pawar, a passionate Cloud and Devops Engineer with a strong background in cloud automation, configuration, and deployment. My journey in the world of technology has been a thrilling adventure, where I've had the privilege to work with cutting-edge tools and practices.

๐Ÿš€ As a DevOps Engineer:

I specialize in automating, configuring, and deploying instances in cloud environments and data centers. My expertise extends to DevOps, GitOps, CI/CD pipeline management, HashiCorp Terraform, and containerization. I'm proficient in AWS and Linux/Unix administration, ensuring robust infrastructure and application performance.

๐Ÿ”ง My Tech Stack:

Front-end skills: HTML, CSS, SCSS, Tailwind CSS, Bootstrap, React, Material-UI, JavaScript DevOps toolbox: GIT, OWASP,Nexus,Trivy, Github, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus, Grafana, Argo CD, AWS EKS.

๐ŸŒ My Cloud Expertise:

I have hands-on experience managing AWS services, including EC2, S3, EBS, VPC, ELB, RDS, IAM, Route53, and more.

๐Ÿ”’ Networking and Security:

My skills include managing networking concepts such as TCP/IP protocols, security policies, and subnet interfacing. I have a strong understanding of infrastructure and networking, covering topics like firewalls, IP addressing, DNS, and more.

๐Ÿ’ก What Sets Me Apart:

I bring a positive attitude, a strong work ethic, and a collaborative spirit to every project. I'm a self-starter, a fast learner, and an effective team player with strong interpersonal skills. In addition to my DevOps skills, I've developed shell scripts (Bash) for automating tasks and have proficiency in Python scripting. My ability to communicate and manage projects, along with a track record of resolving client issues, adds value to every team I work with. If you're looking for a DevOps engineer who is also well-versed in front-end technologies, feel free to connect with me. Let's explore new possibilities and create exceptional technical solutions together!"

Post-build actions in Jenkins pipelines enable you to perform specific tasks or take actions after the completion of a build. This guide explores the usage of post-build actions, particularly focusing on the "always," "success," and "failure" options.

Jenkins Pipeline with Post-Build Actions

groovyCopy codepipeline {
    agent any 

    environment {
        name = "raham"
        loc = "hyderabad"
    }
    stages {
        stage('one') {
            steps {
                sh 'env'
            }
        }
    }
    post {
        always {
            echo "Post-build action: The build is done, regardless of success or failure."
            // Add additional post-build actions here
        }
        success {
            echo "Post-build action: This will execute only if the build is successful."
            // Add success-specific post-build actions here
        }
        failure {
            echo "Post-build action: This will execute only if the build fails."
            // Add failure-specific post-build actions here
        }
    }
}

Explanation

  • always:

    • The block within always will execute whether the build succeeds or fails.

    • Use this for actions that need to occur regardless of the build result.

  • success:

    • The block within success will execute only if the build is successful.

    • Ideal for actions that should occur specifically when the build is successful.

  • failure:

    • The block within failure will execute only if the build fails.

    • Useful for actions tailored to failure scenarios.

Conclusion

Post-build actions provide a powerful mechanism to execute specific tasks after a Jenkins pipeline build. Whether you need actions to occur always, only on success, or only on failure, utilizing post-build actions enhances the flexibility and customization of your Jenkins pipeline workflows. Mastering these options allows you to tailor your automation to respond precisely to different build outcomes.

More from this blog

Kiran Pawar's Blog

122 posts