Skip to content

scripted pipeline with shared library

Notifications You must be signed in to change notification settings

salmanwaheed/jenkins-pipeline-shared-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jenkins-pipeline-shared-library

add the following code into /var/lib/jenkins/jenkins.yaml file and reload existing configuration from JENKINS_URL/manage/configuration-as-code/

unclassified:
  # ....

  globalLibraries:
    libraries:
      - name: shared-library
        defaultVersion: release
        retriever:
          modernSCM:
            scm:
              git:
                id: shared-library
                remote: https://github.com/salmanwaheed/jenkins-pipeline-shared-library.git
                traits:
                  - gitBranchDiscovery

create an item, choose pipeline and configure.

@Library("shared-library")_

jenkins_pipeline {
  agent = "my-agent"

  apps = [
    [ name: "cover", type: "string", defaultBranch: "branch-name", desc: "my string" ],
    [ name: "safeguard", type: "choice", choices: ["item-1", "item-2"], desc: "my choices" ]
  ]

  environments = [
    MY_VAR: "my-value",
    MY_VAR_INT: 12
  ]

  logs = [ days: 60 ]
  githubProject = [ name: "GITHUB NAME", url: "https://github.com" ]

  // upstreams = ["up"]
  // downstreams = ["down", "test"]

  build_commands = [
    echo: "Hi, echo",
    sh: "echo hello, shell"
  ]
}