Skip to content

tknerr/jenkins-pipes-jobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Jenkins Pipes Jobs

Repo containing the job definitions for the Jenkins Pipes demo:

  • it uses Job-DSL to describe WHAT (i.e. which repos) to build
  • the HOW to build is defined in each of the referenced repo's Jenkinsfiles

How it works

There is a seed-job which runs every minute and applies the job-dsl scripts in all the *.groovy files within this repository.

The ci_jobs.groovy sets up the CI build jobs for our demo project. Currently there is only a single repo, but the list could easily be extended:

// define the repos we want to build on CI
def repos = [ 'jenkins-pipes-helloworld' ]

It then loops over all the repos and creates a multibranchPipelineJob (building both master and feature/* branches) for each of them:

// create a multibranch pipeline job for each of the repos
for (repo in repos)
{
  multibranchPipelineJob("${repo}") {

    // build master as well as feature branches
    branchSources {
      git {
        remote("https://github.com/tknerr/${repo}.git")
        includes("master feature/*")
      }
    }
    // check every minute for scm changes as well as new / deleted branches
    triggers {
      periodic(1)
    }
    // don't keep build jobs for deleted branches
    orphanedItemStrategy {
      discardOldItems {
        numToKeep(0)
      }
    }
  }
}

The multibranch pipeline job actually look like folders in the overview:

image

Once you navigate to a specific multibranch pipeline job, you see the individual jobs which are being automatically generated for each of the matching branch patterns:

image

Once a build is started, it will look for a Jenkinsfile and run the build pipeline that is defined therein (see jenkins-pipes-helloworld).

Where to go from here?

Now that you have a minimal "running pipeline jobs via Job-DSL" example running, here are some ideas on how to explore the topic further:

About

Jobs Repository for the Jenkins Pipes demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages