shared-libs

[!TIP] references:

usage

load implicitly

@Library( 'library-name' ) _
@Library( 'library-name@library-version' ) _

// or load multiple
@Library([ 'library-name', 'library-name' ]) _

load dynamically

library identifier: 'library-name@library-version',
        retriever: modernSCM([
                 $class : 'GitSCMSource',
                 remote : 'library-git-url',
          credentialsId : 'git-credentials'
        ])

gerrit refspecs

  • refs/changes

    • mandatory:

      • +refs/heads/*:refs/remotes/@{remote}/*

      • +refs/changes/*:refs/changes/*

    • optional:

      • +refs/changes/*:refs/remotes/@{remote}/*

  • pull-request

    • +refs/pull-requests/*/from:refs/remotes/@{remote}/pr/*

    • +refs/pull/*:refs/remotes/@{remote}/pr/*

    • +refs/heads/*:refs/remotes/@{remote}/*

gerrit

library (
  identifier : "mylibs@" + GERRIT_REFSPEC,
   retriever : modernSCM (
    gerrit( traits: [[
              $class: 'RefSpecsSCMSourceTrait',
              templates: [
                [ value: '+refs/heads/*:refs/remotes/@{remote}/*'   ] ,
                [ value: '+refs/changes/*:refs/changes/*'           ] ,
                [ value: '+refs/changes/*:refs/remotes/@{remote}/*' ]
              ]
            ]],
            credentialsId: 'SSH_CREDENTIAL',
            remote: 'ssh://account@gerrit.sample.com:29418/jenkins/libs'
    )
  )
) _

git

library (
  identifier : 'devops-libs',
  retriever  : modernSCM ([
    $class        : 'GitSCMSource',
    credentialsId : 'SSH_CREDENTIAL',
    remote        : 'ssh://account@gerrit.sample.com:29418/jenkins/libs',
    traits        : [
      gitBranchDiscovery(),
      [
        $class    : 'RefSpecsSCMSourceTrait',
        templates : [
          [ value : '+refs/heads/*:refs/remotes/@{remote}/*'   ] ,
          [ value : '+refs/changes/*:refs/remotes/@{remote}/*' ] ,
          [ value : '+refs/changes/*:refs/changes/*'           ]
        ]
      ]
    ]
  ])
)

Last updated