Skip to content

Commit

Permalink
ADOP LDAP enabled property check - disable generate workspace feature…
Browse files Browse the repository at this point in the history
…s if not available.
  • Loading branch information
Northard, Robert A committed Feb 27, 2017
1 parent 1bc4911 commit 0449df1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
25 changes: 21 additions & 4 deletions bootstrap/Workspace_Management/Generate_Workspace.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def workspaceManagementFolder = folder(workspaceManagementFolderName) { displayN
// Jobs
def generateWorkspaceJob = freeStyleJob(workspaceManagementFolderName + "/Generate_Workspace")

def adopLdapEnabled = '';

try{
adopLdapEnabled = "${ADOP_LDAP_ENABLED}".toBoolean();
}catch(MissingPropertyException ex){
adopLdapEnabled = true;
}

// Setup generateWorkspaceJob
generateWorkspaceJob.with{
parameters{
Expand All @@ -20,7 +28,7 @@ generateWorkspaceJob.with{
preBuildCleanup()
injectPasswords()
maskPasswords()
if("${ADOP_LDAP_ENABLED}".equals("true"))
if(adopLdapEnabled == true)
{
environmentVariables
{
Expand Down Expand Up @@ -48,16 +56,22 @@ fi''')
{
condition
{
stringsMatch('${ADOP_ACL_ENABLED}', 'true', true)
shell('''
if [ "${ADOP_ACL_ENABLED}" == "false" ]
then
exit 1
fi
exit 0
''')
}
runner('Fail')
runner('DontRun')
steps {
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_admin.groovy')
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_developer.groovy')
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_viewer.groovy')
}
}
if("${ADOP_LDAP_ENABLED}".equals("true")) {
if(adopLdapEnabled == true) {
shell('''
# LDAP
${WORKSPACE}/common/ldap/generate_role.sh -r "admin" -n "${WORKSPACE_NAME}" -d "${DC}" -g "${OU_GROUPS}" -p "${OU_PEOPLE}" -u "${ADMIN_USERS}" -f "${OUTPUT_FILE}" -w "${WORKSPACE}"
Expand All @@ -80,6 +94,9 @@ do
done
''')
}
dsl {
external("workspaces/jobs/**/*.groovy")
}
}
scm {
git {
Expand Down
31 changes: 24 additions & 7 deletions workspaces/jobs/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def projectManagementFolder = folder(projectManagementFolderName) { displayName(
// Jobs
def generateProjectJob = freeStyleJob(projectManagementFolderName + "/Generate_Project")

def adopLdapEnabled = '';

try{
adopLdapEnabled = "${ADOP_LDAP_ENABLED}".toBoolean();
}catch(MissingPropertyException ex){
adopLdapEnabled = true;
}

// Setup Generate_Project
generateProjectJob.with{
parameters{
Expand All @@ -27,7 +35,7 @@ generateProjectJob.with{
preBuildCleanup()
injectPasswords()
maskPasswords()
if("${ADOP_LDAP_ENABLED}".equals("true"))
if(adopLdapEnabled == true)
{
environmentVariables
{
Expand All @@ -54,18 +62,24 @@ if [[ "${WORKSPACE_NAME}" =~ ${pattern} ]]; then
fi''')
conditionalSteps
{
condition
{
stringsMatch('${ADOP_ACL_ENABLED}', 'true', true)
}
runner('Fail')
condition
{
shell('''
if [ "${ADOP_ACL_ENABLED}" == "false" ]
then
exit 1
fi
exit 0
''')
}
runner('DontRun')
steps {
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_admin.groovy')
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_developer.groovy')
systemGroovyScriptFile('${WORKSPACE}/workspaces/groovy/acl_viewer.groovy')
}
}
if("${ADOP_LDAP_ENABLED}".equals("true")){
if(adopLdapEnabled == true){
shell('''
# LDAP
${WORKSPACE}/common/ldap/generate_role.sh -r "admin" -n "${WORKSPACE_NAME}" -d "${DC}" -g "${OU_GROUPS}" -p "${OU_PEOPLE}" -u "${ADMIN_USERS}" -f "${OUTPUT_FILE}" -w "${WORKSPACE}"
Expand All @@ -88,6 +102,9 @@ fi''')
done
''')
}
dsl {
external("projects/jobs/**/*.groovy")
}
}
scm {
git {
Expand Down

0 comments on commit 0449df1

Please sign in to comment.