Skip to content

Instantly share code, notes, and snippets.

@gvlx
Created March 30, 2020 17:38
Show Gist options
  • Save gvlx/c92b988a20e100657b6a0531c115d803 to your computer and use it in GitHub Desktop.
Save gvlx/c92b988a20e100657b6a0531c115d803 to your computer and use it in GitHub Desktop.
Jenkins SCM helper shared library
#!/usr/bin/env groovy
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.impl.*
def call(String url) {
println url;
}
/**
* @param url - svn server url
* @param user - svn server username
* @param password - svn server password
**/
def listCred(Map serverAccess) {
def credential = CredentialsProvider.lookupCredentials(
UsernamePasswordCredentialsImpl.class,
Jenkins.instance, null, null
).find { it.id == serverAccess?.credential }
if (credential?.id) return sh (
script: """\
svn list ${serverAccess.url} \
--no-auth-cache \
--username ${credential.username} \
--password ${credential.password?.getPlainText()}\
""",
returnStdout: true
).split(/\/?\s*(\r|\n|\z)/)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment