Continuous Integration (CI) and Continuous Deployment (CD) are essential practices in modern software development, enabling teams to streamline the development process, catch bugs early, and deliver updates quickly and reliably. Jenkins, an open-source automation server, is a popular choice for implementing CI/CD pipelines. In this article, we will guide you through the process of setting up a Freestyle Jenkins project to build your application whenever there is a new commit on GitHub.
- GitHub Repository - Your application code must be hosted on GitHub or You can fork this repo https://github.com/shivpateriya/cicd-pipeline-train-schedule-pipelines.git
- Jenkins Installation: Jenkins should be installed and running on a server.
- GitHub Token: You will need a GitHub token to allow Jenkins to access your GitHub repository. Generate a Personal Access Token from your GitHub account settings with the necessary permissions (repo scope is required). For reference https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-create-a-GitHub-Personal-Access-Token-example
- Navigate to "Manage Jenkins" > "Configure System."
- Scroll down to the "GitHub" section.
- Click on the "Add GitHub Server" button.
- Enter a unique name for your GitHub server, such as "GitHub" or "GitHub.com."
- In the "API Credentials" section, click on the "Add" button and provide your GitHub Personal Access Token. This token will allow Jenkins to interact with your GitHub repository.
- Click "Add" to save your credentials.
- Under "GitHub Server API URL," leave it as the default (https://api.github.com).
- Click "Save."
- From the Jenkins dashboard, click on "New Item" on the left-hand side.
- Enter a name for your project and choose "Freestyle project."
- Click "OK" to create the project.
- In the project configuration, scroll down to the "Source Code Management" section.
- Select "Git" as the Source Code Management system.
- Enter your GitHub repository's URL in the "Repository URL" field, for example, https://github.com/shivpateriya/cicd-pipeline-train-schedule-pipelines.git
- Under "Credentials," select the GitHub credentials you previously added.
- In the "Branches to build" section, enter the branch you want to build (e.g., "main" or "master").
- Scroll down to the "Build Triggers" section and check the box for "GitHub hook trigger for GITScm polling." This setting will trigger a build whenever there's a new commit on GitHub.
- In the "Build" section, add build steps specific to your project. For example, you might use shell commands to build and deploy your application.
- Click "Save" to save your project configuration.
Now that your Freestyle Jenkins project is configured, it will automatically build your application whenever there is a new commit to the specified branch on your GitHub repository. To test the setup, make a new commit to your repository and observe Jenkins automatically starting a build.
Looking for Spring 2025 Internship | MSCS @UFL | EX-LTIMindtree
1 年Good Job bro!