Skip to main content

Configure Jenkins pipeline job

·1 min

In one of my previous posts, I discussed configuring multibranch pipeline seed jobs using Jenkins configuration as code plugin

Below is an example of configuring a declarative pipeline job from a bitbucket repo, running at midnight every day

- script: >
    pipelineJob('sample-job') {
      definition {
          cpsScm {
            scriptPath 'job1/Jenkinsfile' ## If the Jenkins job is in a nested folder
            scm {
              git {
                  remote {
                    url 'https://github.com/Vikaspogu/sample-repo'
                    credentials 'sample-creds'
                  }
                  branch '*/master'
                  extensions {}
              }
            }
            triggers {
              cron('@midnight')
            }
          }
      }
    }