How to make Pipeline job trigger on GitHub push?

34 views
Skip to first unread message

Ola Eldøy

unread,
Nov 18, 2016, 8:58:33 AM11/18/16
to Jenkins Users
I am setting up a pipeline job that checks out four GitHub repositories. If changes are pushed to any of these repositories, I want the job to kick off.

How should I go about this?

Below is my pipeline script (names have been changed)

node() {
  stage ('Checkout') {
      parallel 'Checkout':{
        dir('MyProduct') {
          git url: 'g...@github.com:MyCompany/MyProduct.git'
        }
        dir('RelatedRepo1') {
          git url: 'g...@github.com:MyCompany/RelatedRepo1.git'
        }
        dir('RelatedRepo2') {
          git url: 'g...@github.com:MyCompany/RelatedRepo2.git'
        }
        dir('RelatedRepo3') {
          git url: 'g...@github.com:MyCompany/RelatedRepo3.git'
        }
      }
  }  
  stage ('Build') {
    bat 'nuget restore "MyProduct/MyProduct all projects.sln"'
    bat '"C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\msbuild.exe" "MyProduct\\MyProduct all projects.sln" /p:Configuration=Release'
  }
  stage ('Test') {
    bat '"C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" "MyProduct\\UnitTestMyProduct\\bin\\Release\\UnitTestMyProduct.dll"'
    step([$class: 'NUnitPublisher', testResultsPattern: 'TestResult.xml', debug: false, keepJUnitReports: true, skipJUnitArchiver:false, failIfNoResults: true])
  }
  stage ('Archive') {
    archiveArtifacts 'MyProduct\\MyProduct\\bin\\Release\\*'
  }
}

P.S. Any other tips for improvement are happily accepted.

Ola Eldøy

unread,
Nov 25, 2016, 2:39:35 AM11/25/16
to Jenkins Users
I have found a way to get this working, by setting up four Jenkins "Freestyle projects" that trigger when code is pushed to their corresponding GitHub repos. Then, in the master pipeline project, I add the projects under "Build Triggers" and "Build after other projects are built"

I was hoping to solve this by using a pipeline project only, but perhaps it is still "early days" for the Jenkins Pipeline. I'm waiting for better documentation and hoping for more feedback in the future.
Reply all
Reply to author
Forward
0 new messages