Skip to content

Commit

Permalink
[BACKLOG-23041] Enforces job names strategy to be of pattern [a-z0-9-…
Browse files Browse the repository at this point in the history
…\.]{3,50}
  • Loading branch information
tmcsantos committed May 4, 2018
1 parent 15839cb commit e5fff6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion docker/jenkins/bootstrap/configureGlobalSettings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
- CSRF Protection
- Disable CLI remoting
- Markup Formatter
- Project name restrictions
*/
import hudson.markup.RawHtmlMarkupFormatter
import hudson.security.csrf.DefaultCrumbIssuer
import jenkins.CLI
import jenkins.model.Jenkins
import jenkins.model.ProjectNamingStrategy
import jenkins.security.s2m.AdminWhitelistRule
import org.apache.commons.io.FileUtils

Expand Down Expand Up @@ -69,7 +71,7 @@ if (!jenkins.isQuietingDown()) {
/*
Prevent Cross Site Request Forgery exploits
*/
jenkins.setCrumbIssuer(new DefaultCrumbIssuer(true))
jenkins.crumbIssuer = new DefaultCrumbIssuer(true)
logger.info 'Configured CSRF Protection'

/*
Expand All @@ -80,6 +82,9 @@ if (!jenkins.isQuietingDown()) {
logger.info 'Configured Markup Formatter'
}

jenkins.projectNamingStrategy =
new ProjectNamingStrategy.PatternProjectNamingStrategy('[a-z0-9-\\.]{3,50}',"", true)

jenkins.save()

CLI.get().setEnabled(false)
Expand Down
2 changes: 1 addition & 1 deletion docker/jenkins/bootstrap/configureSamplePipelineJob.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.jenkinsci.plugins.workflow.job.WorkflowJob

def jenkins = Jenkins.getInstance()
// workdir names with spaces causes problems in javascript builds
def jobName = 'sample_pipeline'
def jobName = 'sample-pipeline'
def env = System.getenv()

if (!jenkins.isQuietingDown()) {
Expand Down
3 changes: 1 addition & 2 deletions docker/jenkins/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ while [[ $# -gt 0 ]]; do
export force="ok"
;;
* )
echo "Unknown option: $opt"
exit 1
die "Unknown option: $opt"
;;
esac
shift;
Expand Down

0 comments on commit e5fff6f

Please sign in to comment.