Skip to content

Commit

Permalink
fix: saml job
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeemshahzad committed Jan 8, 2024
1 parent 1f504e8 commit 8adea2f
Showing 1 changed file with 54 additions and 49 deletions.
103 changes: 54 additions & 49 deletions devops/jobs/SAMLSSLExpirationCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,70 @@
package devops.jobs
import static org.edx.jenkins.dsl.Constants.common_logrotator

class SAMLSSLExpirationCheck{
public static def job = { dslFactory, extraVars ->
assert extraVars.containsKey('DEPLOYMENTS') : "Please define DEPLOYMENTS. It should be a list of strings."
assert !(extraVars.get('DEPLOYMENTS') instanceof String) : "Make sure DEPLOYMENTS is a list and not a string"
extraVars.get('DEPLOYMENTS').each { deployment, configuration ->
configuration.environments.each { environment, inner_config ->
dslFactory.job(extraVars.get("FOLDER_NAME","Monitoring") + "/saml-ssl-expiration-check-${environment}-${deployment}") {
logRotator common_logrotator
class SAMLSSLExpirationCheck {
public static def job = {
dslFactory,
extraVars ->
assert extraVars.containsKey('DEPLOYMENTS'): "Please define DEPLOYMENTS. It should be a list of strings."
assert!(extraVars.get('DEPLOYMENTS') instanceof String): "Make sure DEPLOYMENTS is a list and not a string"
extraVars.get('DEPLOYMENTS').each {
deployment,
configuration ->
configuration.environments.each {
environment,
inner_config ->
dslFactory.job(extraVars.get("FOLDER_NAME", "Monitoring") + "/saml-ssl-expiration-check-${environment}-${deployment}") {
logRotator common_logrotator

def gitCredentialId = extraVars.get('SECURE_GIT_CREDENTIALS', '')

def gitCredentialId = extraVars.get('SECURE_GIT_CREDENTIALS','')
parameters {
stringParam('MONITORING_SCRIPTS_REPO', extraVars.get('MONITORING_SCRIPTS_REPO', '[email protected]:edx/monitoring-scripts.git'),
'Git repo containing edX monitoring scripts, which contains the ssl expiration check script.')
stringParam('MONITORING_SCRIPTS_BRANCH', extraVars.get('MONITORING_SCRIPTS_BRANCH', 'master'),
'e.g. tagname or origin/branchname')
}

parameters{
stringParam('MONITORING_SCRIPTS_REPO', extraVars.get('MONITORING_SCRIPTS_REPO', '[email protected]:edx/monitoring-scripts.git'),
'Git repo containing edX monitoring scripts, which contains the ssl expiration check script.')
stringParam('MONITORING_SCRIPTS_BRANCH', extraVars.get('MONITORING_SCRIPTS_BRANCH', 'master'),
'e.g. tagname or origin/branchname')
}

multiscm{
git {
remote {
url('$MONITORING_SCRIPTS_REPO')
branch('$MONITORING_SCRIPTS_BRANCH')
if (gitCredentialId) {
credentials(gitCredentialId)
}
}
extensions {
cleanAfterCheckout()
pruneBranches()
relativeTargetDirectory('monitoring-scripts')
}
}
multiscm {
git {
remote {
url('$MONITORING_SCRIPTS_REPO')
branch('$MONITORING_SCRIPTS_BRANCH')
if (gitCredentialId) {
credentials(gitCredentialId)
}
}
extensions {
cleanAfterCheckout()
pruneBranches()
relativeTargetDirectory('monitoring-scripts')
}
}
}


triggers {
cron("H 15 * * * ")
}

environmentVariables {
env('REGION', extraVars.get('REGION', 'us-east-1'))
env('DAYS', extraVars.get('DAYS', 90))
env('SAML_SECRET', inner_config.get('saml_secret'))
env('SECRET_KEY', inner_config.get('secret_key'))
}
triggers {
cron("H 15 * * * ")
}

steps {
shell(dslFactory.readFileFromWorkspace('devops/resources/saml-ssl-expiration-check.sh'))
}
environmentVariables {
env('REGION', extraVars.get('REGION', 'us-east-1'))
env('DAYS', extraVars.get('DAYS', 90))
env('SAML_SECRET', inner_config.get('saml_secret'))
env('SECRET_KEY', inner_config.get('secret_key'))
}

if (extraVars.get('NOTIFY_ON_FAILURE')) {
publishers {
mailer(extraVars.get('NOTIFY_ON_FAILURE'), false, false)
steps {
shell(dslFactory.readFileFromWorkspace('devops/resources/saml-ssl-expiration-check.sh'))
}
}

if (extraVars.get('NOTIFY_ON_FAILURE')) {
publishers {
mailer(extraVars.get('NOTIFY_ON_FAILURE'), false, false)
}
}

}
}
}
}
}

0 comments on commit 8adea2f

Please sign in to comment.