-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from DontShaveTheYak/develop
Release v0.11.0
- Loading branch information
Showing
45 changed files
with
1,873 additions
and
74 deletions.
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,37 @@ | ||
FROM jenkins/jenkins:latest-jdk11 | ||
|
||
# Install docker into the container | ||
USER root | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
wget \ | ||
git \ | ||
curl \ | ||
python3 \ | ||
python3-pip && \ | ||
python3 -m pip install --upgrade pip && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install and setup docker into the container | ||
RUN groupadd -g 118 docker && curl -fsSL https://get.docker.com -o get-docker.sh && \ | ||
sh get-docker.sh && usermod -aG docker jenkins | ||
|
||
USER jenkins | ||
|
||
# Install pre-commit and dependencies | ||
COPY tests/requirements.txt /tmp | ||
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
## Plugins | ||
COPY --chown=jenkins:jenkins docker/*-plugins.txt /usr/share/jenkins/ref/ | ||
RUN cat /usr/share/jenkins/ref/lib-plugins.txt >> /usr/share/jenkins/ref/runner-plugins.txt && \ | ||
jenkins-plugin-cli -f /usr/share/jenkins/ref/runner-plugins.txt && \ | ||
jenkins-plugin-cli --plugins job-dsl build-blocker-plugin | ||
|
||
## Setup init scripts | ||
COPY --chown=jenkins:jenkins .devcontainer/*.groovy docker/init_scripts/src/main/groovy/* /usr/share/jenkins/ref/init.groovy.d/ | ||
|
||
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false | ||
ENV JENKINS_SLAVE_AGENT_PORT= | ||
ENV JENKINS_OPTS="--httpPort=80" | ||
ENV PATH="/var/jenkins_home/.local/bin:$PATH" |
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,58 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/docker-existing-dockerfile | ||
{ | ||
"name": "jenkins-std-lib", | ||
// Sets the run context to one level up instead of the .devcontainer folder. | ||
"context": "..", | ||
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. | ||
"dockerFile": "../.devcontainer/Dockerfile", | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"editor.insertSpaces": true, | ||
"editor.tabSize": 4, | ||
"groovy.classpath": [ | ||
"/var/jenkins_home/pipeline-library/build/dependencies" | ||
] | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-azuretools.vscode-docker", | ||
"dontshavetheyak.jenkins-extension-pack", | ||
"eamodio.gitlens", | ||
"ms-python.python" | ||
], | ||
// By default vscode sets the entrypoint to infinite sleep loop | ||
"overrideCommand": false, | ||
// Put the workspace in the jenkins home directory so it can be installed into the jenkins as a shared library. | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/var/jenkins_home/pipeline-library,type=bind,consistency=cached", | ||
"workspaceFolder": "/var/jenkins_home/pipeline-library", | ||
"containerEnv": { | ||
"DIND_WORKSPACE": "${localWorkspaceFolder}" | ||
}, | ||
// Set the build args | ||
// "build": { | ||
// "args": { | ||
// "PRE_COMMIT_VERSION": "latest", | ||
// "TERRAFORM_VERSION": "latest", | ||
// "TERRAFORM_DOCS_VERSION": "latest", | ||
// "TERRASCAN_VERSION": "latest", | ||
// "TFLINT_VERSION": "latest", | ||
// "TFSEC_VERSION": "latest" | ||
// } | ||
// }, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [8080, 50000], | ||
"appPort": [ | ||
"5050:80" | ||
], | ||
// Uncomment the next line to run commands after the container is created - for example installing curl. | ||
"postStartCommand": "./gradlew downloadJars", | ||
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust | ||
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | ||
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. | ||
"mounts": [ | ||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" | ||
], | ||
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode" | ||
} |
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,27 @@ | ||
#!groovy | ||
/* groovylint-disable NoDef, NoWildcardImports, UnnecessaryGetter, UnnecessarySetter, VariableTypeRequired */ | ||
import jenkins.model.* | ||
import hudson.security.* | ||
import hudson.util.* | ||
import jenkins.install.* | ||
import javaposse.jobdsl.plugin.GlobalJobDslSecurityConfiguration | ||
import jenkins.model.GlobalConfiguration | ||
|
||
// You should not actually do this on your real jenkins. | ||
println('==== Disable Jenkins Security') | ||
|
||
println('== Disable JobDSL Security') | ||
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration).useScriptSecurity = false | ||
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration).save() | ||
|
||
final Jenkins jenkins = Jenkins.getInstance() | ||
|
||
println('== Disable Setup Wizard') | ||
jenkins.setInstallState(InstallState.INITIAL_SETUP_COMPLETED) | ||
|
||
println('== Disable Authentication') | ||
def strategy = new AuthorizationStrategy.Unsecured() | ||
jenkins.setAuthorizationStrategy(strategy) | ||
|
||
jenkins.save() | ||
println('== Disable Security complete') |
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,98 @@ | ||
#!groovy | ||
/* groovylint-disable GStringExpressionWithinString, JavaIoPackageAccess, NoDef, NoWildcardImports, UnnecessaryGetter, UnnecessaryObjectReferences, UnnecessarySetter, VariableTypeRequired */ | ||
import hudson.model.FreeStyleProject | ||
import hudson.triggers.SCMTrigger | ||
import javaposse.jobdsl.plugin.* | ||
import jenkins.model.Jenkins | ||
import hudson.plugins.filesystem_scm.FSSCM | ||
|
||
println('==== Creating seed job') | ||
final String jobName = 'seed-job' | ||
final File jobsDir = new File('/var/jenkins_home/pipeline-library/jobs') | ||
|
||
final String dslScript = '''\ | ||
import java.nio.file.Path | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
Files.walk(Paths.get('/var/jenkins_home/pipeline-library/jobs')).findAll { Path item -> | ||
item.toString().contains('.groovy') | ||
}.forEach { Path item -> | ||
final String fileName = item.getFileName() | ||
final String jobName = fileName.replace('_', '-').replace('.groovy', '') | ||
final File jenkinsFile = item.toFile() | ||
println("Creating job for ${fileName}") | ||
pipelineJob(jobName) { | ||
definition { | ||
cpsScm { | ||
lightweight(true) | ||
scm { | ||
filesystem { | ||
// The file path for the source code. | ||
path(jenkinsFile.getParent()) | ||
// If true, the system will delete all existing files/sub-folders in workspace before checking-out. | ||
clearWorkspace(false) | ||
// If true, the system will copy hidden files and folders as well. | ||
copyHidden(false) | ||
filterSettings { | ||
includeFilter(false) | ||
} | ||
} | ||
} | ||
scriptPath(fileName) | ||
} | ||
} | ||
} | ||
} | ||
''' | ||
|
||
final FSSCM fileScm = new FSSCM(jobsDir.getPath(), false, false, false, false, null) | ||
|
||
final Jenkins jenkins = Jenkins.getInstance() | ||
|
||
def existingJob = jenkins.items.find { def job -> | ||
job.name == jobName | ||
} | ||
|
||
if (existingJob) { | ||
println('== Existing seed job found, exiting') | ||
return | ||
} | ||
|
||
final SCMTrigger scmTrigger = new SCMTrigger('* * * * *') | ||
final ExecuteDslScripts dslBuilder = new ExecuteDslScripts() | ||
|
||
// dslBuilder.setSandbox(true) | ||
dslBuilder.setScriptText(dslScript) | ||
dslBuilder.setUseScriptText(true) | ||
dslBuilder.setIgnoreExisting(false) | ||
dslBuilder.setIgnoreMissingFiles(false) | ||
dslBuilder.setFailOnMissingPlugin(true) | ||
dslBuilder.setRemovedJobAction(RemovedJobAction.DELETE) | ||
dslBuilder.setRemovedViewAction(RemovedViewAction.DELETE) | ||
dslBuilder.setLookupStrategy(LookupStrategy.JENKINS_ROOT) | ||
|
||
dslProject = new FreeStyleProject(jenkins, jobName) | ||
dslProject.scm = fileScm | ||
|
||
|
||
dslProject.addTrigger(scmTrigger) | ||
dslProject.createTransientActions() | ||
dslProject.getPublishersList().add(dslBuilder) | ||
|
||
println('== Adding Seed Job to Jenkins') | ||
jenkins.add(dslProject, jobName) | ||
|
||
println('== Triggering Seed Job polling') | ||
scmTrigger.start(dslProject, true) | ||
|
||
println('== Seed Job setup complete') |
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -2,10 +2,17 @@ import jenkins.model.Jenkins | |
import jenkins.model.JenkinsLocationConfiguration | ||
import hudson.tasks.Mailer | ||
|
||
println('== Configuring the system...') | ||
println('==== System Configuration') | ||
|
||
// We do not wait for anything | ||
Jenkins.instance.quietPeriod = 0 | ||
|
||
JenkinsLocationConfiguration.get().adminAddress = '[email protected]' | ||
// get Jenkins location configuration | ||
JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get() | ||
|
||
config.url = 'http://localhost:5050' | ||
config.adminAddress = '[email protected]' | ||
Mailer.descriptor().defaultSuffix = '@non.existent.email' | ||
|
||
config.save() | ||
println('== System Configuration complete') |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
git:4.7.2 | ||
sshd:3.0.3 | ||
workflow-aggregator:2.6 |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
configuration-as-code-groovy:1.1 | ||
filesystem_scm:2.1 | ||
jdk-tool:1.5 | ||
git |
Oops, something went wrong.