How to trigger a build on commit to branch in declarative pipeline

0 votes
Jul 8 in Jenkins by Madhura
• 130 points
68 views

1 answer to this question.

+1 vote

Hi@Madhura,

You can use triggers keyword in your DSL code as shown below.

 triggers {
       // poll repo every 2 minute for changes
       pollSCM('*/2 * * * *')

It will check every two seconds if anything changes occur and build your Job automatically.

answered Jul 9 by MD
• 42,420 points

Related Questions In Jenkins

+2 votes
2 answers

How to trigger a Jenkins pipeline A in another Jenkins pipeline B?

If you are talking about executing another ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 55,620 points
24,993 views
0 votes
2 answers

How to auto build a job in jenkins if there is any change in code on Github repository?

To automatically run build on code commit, follow ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 55,620 points
7,903 views
+1 vote
1 answer

How to extract a substring of a string in a declarative pipeline code?

This would have been more easier using ...READ MORE

answered Aug 16, 2019 in Jenkins by Sirajul
• 55,620 points
8,844 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,420 points
603 views
0 votes
1 answer
0 votes
1 answer

How to merge two branch in GitHub using jenkins?

Hi@akhtar, To implement this task you can follow ...READ MORE

answered May 7 in Jenkins by MD
• 42,420 points
464 views
0 votes
1 answer

how to pass a file to downstream job in jenkins?

Hi@Sourabh, You can do this task by sharing ...READ MORE

answered May 27 in Jenkins by MD
• 42,420 points
141 views