-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OSRFcredentials class and test for DSL (#1212)
* Add credentials class and test for DSL Requires right credentials to be deployed to the credentials plugin --------- Signed-off-by: Jose Luis Rivero <[email protected]>
- Loading branch information
Showing
2 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package _configs_ | ||
|
||
import javaposse.jobdsl.dsl.Job | ||
|
||
class OSRFCredentials | ||
{ | ||
static void setOSRFCrendentials(Job job, List crendentials_list) | ||
{ | ||
job.with | ||
{ | ||
wrappers { | ||
// Credential name needs to be in sync with provision code at infra/osrf-chef repo | ||
credentialsBinding { | ||
crendentials_list.each { credential_keyword -> | ||
if (credential_keyword == 'OSRFBUILD_GITHUB_TOKEN') { | ||
usernamePassword('OSRFBUILD_USER', | ||
'OSRFBUILD_TOKEN', | ||
'github-osrfbuild-apitoken') | ||
} else if (credential_keyword == 'OSRFBUILD_JENKINS_TOKEN') { | ||
usernamePassword('OSRFBUILD_JENKINS_USER', | ||
'OSRFBUILD_JENKINS_TOKEN', | ||
'jenkins-osrfbuild-apitoken') | ||
} else { | ||
print ("Credential not support: ${credential_keyword}") | ||
exit(1) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
static void allowOsrfbuildToRunTheBuild(Job job) | ||
{ | ||
job.with { | ||
authorization { | ||
permission('hudson.model.Item.Read', 'osrfbuild') | ||
permission('hudson.model.Item.Build', 'osrfbuild') | ||
} | ||
} | ||
} | ||
} |
This file contains 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