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
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:
- Configure the
devpipeline to trigger on commits to thedevbranch:
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.'
}
}
}
- Configure the
stagepipeline to be manually triggered:
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
devpipeline is set to poll the SCM every 5 minutes(pollSCM('H/5 * * * *')). This should ensure that any commits to thedevbranch will trigger thedevpipeline. I know, that’s not really “triggered by commit”, but… - The
stagepipeline 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… ![]()