Skip to content

Instantly share code, notes, and snippets.

@monodot
Created May 29, 2019 16:55
Show Gist options
  • Save monodot/f7a2b91efd5c2408eeebbc91fed2e819 to your computer and use it in GitHub Desktop.
Save monodot/f7a2b91efd5c2408eeebbc91fed2e819 to your computer and use it in GitHub Desktop.
Declarative Jenkins pipeline which reads a shared library from a private Git repo
/*
Firstly, you need to add a new Credential in Jenkins to access your Git.
Grab the ID of the Credential and use it in the credentialsId field below.
*/
library identifier: 'mylibraryname@master',
//'master' refers to a valid git-ref
//'mylibraryname' can be any name
retriever: modernSCM([
$class: 'GitSCMSource',
credentialsId: 'your-credentials-id',
remote: 'https://github.com/monodot/private-jenkins-library.git'
])
pipeline {
agent any
stages {
stage('Demo') {
steps {
echo 'Hello world'
sayHello 'Dave'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment