Index

Jenkins-dsl hello world

simple plugins file
configuration-as-code:1.35
configuration-as-code-support:1.19
git:4.2.2
greenballs:1.15
job-dsl:1.74
matrix-auth:2.5
simple configuration.yaml
jenkins:
  crumbIssuer: "standard"

  securityRealm:
    local:
      users:
        - id: admin
          password: ${adminpw:-admin}

  authorizationStrategy:
    globalMatrix:
      grantedPermissions:
        - "Overall/Administer:admin"
        - "Overall/Read:anonymous"
        - "View/Read:anonymous"
        - "Job/Read:anonymous"
        - "Job/Build:anonymous"

jobs:
  - file: "/data/jenkins/seed_job.groovy"

security:
  globalJobDslSecurityConfiguration:
    useScriptSecurity: false
hello world job
job('seed-job') {
    displayName('Seed Job')
    steps {
	    shell('echo "hello from: \$PWD"')
    }
}

docker

dockerfile
FROM jenkins/jenkins:2.230
USER jenkins
COPY docker/plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
ENV JAVA_OPTS "-Djenkins.install.runSetupWizard=false ${JAVA_OPTS:-}"
ENV CASC_JENKINS_CONFIG=/data/jenkins/configuration.yaml
building the image and tagging it as "demo"
docker build --network bridge --tag demo:latest --file docker/dockerfile .
running the image
docker run --network bridge --volume $PWD/mountfs:/data/jenkins --publish 8080:8080 --rm demo:latest