今日已更新 129 条资讯 | 累计 29863 条内容
关于我们

Automating the Workflow: My Journey from Jenkins Freestyle Jobs to Declarative Pipelines

Zakariyau Mukhtar 2026年08月10日 05:16 2 次阅读 来源:Dev.to

The Infrastructure: Setting Up Jenkins on AWS The foundation of this project began by provisioning an Ubuntu EC2 instance on AWS. Setting up the environment meant defining strict networking rules (opening Port 22 for SSH and Port 8080 for the Jenkins UI) and structuring the Jenkins environment with clear access controls. In Jenkins, maintaining a secure and organized environment generally falls into two roles: Administrators: Responsible for managing the Jenkins cluster, installing necessary plugins, and handling data backups. Users: Focused purely on creating jobs to run their respective workflows. The Magic of Docker-out-of-Docker (DooD) One of the most critical architectural choices was deciding how to let Jenkins build Docker images without installing a heavy, nested Docker engine inside the Jenkins container itself. The solution was a Docker-out-of-Docker configuration. By running the following command, I spun up the Jenkins container while binding it directly to the host machine's Docker socket: docker run -p 8080:8080 -p 50000:50000 -d \ -v jenkins_home:/var/jenkins_home \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $( which docker ) :/usr/bin/docker jenkins/jenkins:lts This single command did a lot of heavy lifting. It mapped port 8080 for the UI and 50000 for Jenkins agent communication. More importantly, mapping /var/run/docker.sock gave the Jenkins container the ability to pass docker build and docker push commands directly to the EC2 host’s Docker engine. (Just remember to ensure your jenkins user has the right permissions to access that socket!). Hitting the Wall: The Limitations of Freestyle Jobs Initially, I set up the application lifecycle running npm install , npm test , and npm pack using a standard Jenkins Freestyle job. Freestyle jobs are great for quick, isolated tasks. However, their limitations become glaringly obvious when you try to build a project with multiple automation steps. Orchestrating a complex workflow by chaining multiple Fr

本文内容来源于互联网,版权归原作者所有
查看原文