# Commit based trigger

**URL:** <https://community.jenkins.io/t/commit-based-trigger/28489>\
**Category:** Community\
**Tags:** question\
**Created:** [March 19, 2025, 7:48am UTC](https://community.jenkins.io/t/commit-based-trigger/28489 "2025-03-19T07:48:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![satyasaladi1](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@satyasaladi1](https://community.jenkins.io/u/satyasaladi1)\
**Post date:** [March 19, 2025, 7:48am UTC](https://community.jenkins.io/t/commit-based-trigger/28489/1 "2025-03-19T07:48:15Z")

</div>

I have dev and stage environment i configure commit based trigger for dev env for dev branch if any commit happens it will trigger till now it was fine if i ran stage pipeline manually it will not trigger dev commit for the next time if i ran it manually it was working if i ran stage it will override the existing help me to fix this issue my requirement was if i commit any changes in dev it got trigger even if i manually trigger the stage pipeline help me to fix this here my pipeline

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [March 19, 2025, 1:10pm UTC](https://community.jenkins.io/t/commit-based-trigger/28489/2 "2025-03-19T13:10:44Z")

</div>

To ensure that your `dev` environment pipeline triggers on commits to the `dev` branch even if the `stage` pipeline is manually triggered, I think you would need to make sure that the triggers for the `dev` pipeline are correctly configured and isolated from the `stage` pipeline.

Here is an untested example of how you could maybe configure your Jenkins pipeline to achieve this:

1. Configure the `dev` pipeline to trigger on commits to the `dev` branch:

```auto
pipeline {
    agent any
    triggers {
        pollSCM('H/5 * * * *') // Polls the SCM every 5 minutes
    }
    stages {
        stage('Build') {
            steps {
                // Your build steps for the dev environment
                echo 'Building dev environment...'
            }
        }
        stage('Test') {
            steps {
                // Your test steps for the dev environment
                echo 'Testing dev environment...'
            }
        }
    }
    post {
        always {
            // Actions to perform after the pipeline run
            echo 'Dev pipeline completed.'
        }
    }
}

```

1. Configure the `stage` pipeline to be manually triggered:

```auto
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                // Your build steps for the stage environment
                echo 'Building stage environment...'
            }
        }
        stage('Test') {
            steps {
                // Your test steps for the stage environment
                echo 'Testing stage environment...'
            }
        }
    }
    post {
        always {
            // Actions to perform after the pipeline run
            echo 'Stage pipeline completed.'
        }
    }
}

```

In this configuration:

- The `dev` pipeline is set to poll the SCM every 5 minutes `(pollSCM('H/5 * * * *'))`. This should ensure that any commits to the `dev` branch will trigger the `dev` pipeline. I know, that’s not really “triggered by commit”, but…
- The `stage` pipeline does not have any triggers configured, so it will only run when manually triggered.

This setup should ensure that the `dev` pipeline will always trigger on commits to the `dev` branch, regardless of whether the `stage` pipeline is manually triggered or not.

I’m sure someone else will find a much better way to do it, but in the meantime… 😊
