Created
March 30, 2020 17:38
-
-
Save gvlx/c92b988a20e100657b6a0531c115d803 to your computer and use it in GitHub Desktop.
Jenkins SCM helper shared library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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