'Jenkins DSL job pass a variable to github class?
I would like to use a loop to seed jenkinsfiles jobs from diff repos in an org, so I was wondering if this is valid:
services.each { service, option ->
....
....
definition {
cpsScm {
scriptPath(jenkinspath + "/" + "Jenkinsfile")
scm {
git {
branch('master')
remote {
github('MyOrg/'${repo}, 'https', 'github.com')
credentials('my-ro-token')
}
}
}
}
I have tried with $repo, repo, ${repo}, "$repo" '${repo}', and more, and nothing works. I could not find any place if that is even possible, de documentation says just this:
github(String ownerAndProject, String branch = null, String protocol = 'https', String host = 'github.com', Closure closure = null)
Any help will be highly appreciated!
Solution 1:[1]
Nerver mind, it works as the other env variables on DSL jobs.
def repourl = "myorg/myrepo"
def myrepo = "somerepo"
...
github(repourl, 'https', 'github.com')
or
github('myorg' + '/' + myrepo, 'https', 'github.com')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | harguer |
