Free Style Pipeline in Jenkins

 

Step 1: Install Jenkins and Access the Dashboard

  1. Ensure Jenkins is installed and running. You can access it via http://<your_server_ip>:8080 (default port).
  2. Log in to the Jenkins dashboard with your credentials.

Step 2: Create a New Job

  1. On the Jenkins dashboard, click "New Item".
  2. In the "Enter an item name" field, provide a name for your pipeline (e.g., MyFreestylePipeline).
  3. Select "Freestyle project" and click "OK".

Step 3: Configure the Job

  1. In the General section, add a description (optional).
  2. Check "Discard old builds" if you want to limit the number of builds stored.
  3. (Optional) Check "Restrict where this project can be run" and specify a label if you want to run this job on specific nodes.

Step 4: Configure Source Code Management

  1. In the Source Code Management section:
    • Select "Git" (or other version control).
    • Enter your repository URL.
    • Provide credentials if necessary

Step 5: Add Build Steps

  1. In the Build section, click "Add build step".
  2. Choose a build step based on your requirements:
    • Execute shell: Use shell commands (Linux/Mac).
    • Execute Windows batch command: Use batch commands (Windows).
    • Invoke Ant/Gradle: For Java-based builds.
Example for a shell script:
bash
echo "Building the project" ./build.sh echo "Build completed"

Step 6: Add Post-Build Actions

  1. In the Post-build Actions section, you can add:
    • Archive the artifacts: Save build outputs.
    • Email notifications: Notify stakeholders of build status.
    • Trigger other jobs: Start downstream projects.

Step 7: Save and Build

  1. Click "Save" to store your job configuration.
  2. To test the pipeline, click "Build Now" on the job's dashboard.
  3. View build progress by clicking "#1" under the Build History.

Example Use Case

Simple Build Script

Suppose your project repository has a script (build.sh) that compiles the code. Configure the Execute shell step with:

bash
git pull origin main
chmod +x build.sh ./build.sh

Comments

Popular posts from this blog

Ag Grid Angular

.NET Watcher in a .NET Core API

Power Shell UI Forms