Skip to content

Commit

Permalink
Merge pull request #102 from DontShaveTheYak/develop
Browse files Browse the repository at this point in the history
Release v0.8.0
  • Loading branch information
shadycuz authored Jul 16, 2021
2 parents 7f1e7d2 + 4c9ce1e commit d54b6c4
Show file tree
Hide file tree
Showing 15 changed files with 493 additions and 255 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 'jobs/**'
- 'src/**'
- 'tests/**'
- 'docker/**'

jobs:
linting:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ We recommend the following plugins:
```
* [AnsiColor](https://plugins.jenkins.io/ansicolor/) - To get color coded log messages from our logging package.

The required plugins and versions to enable complete library functionality can be found in [lib-plugins.txt](./docker/lib-plugins.txt).

*Note: Individual library functions may have their own requirements. See the [docs][doc-url]*

### Usage
Expand Down
42 changes: 12 additions & 30 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
FROM jenkins/jenkinsfile-runner:build-mvncache as jfr-mvncache
FROM jenkins/jenkinsfile-runner:latest

###
# Build stage
###
FROM maven:3.5.4 as jfr-build
ENV MAVEN_OPTS=-Dmaven.repo.local=/mavenrepo
COPY --from=jfr-mvncache /mavenrepo /mavenrepo
ADD pom.xml /jenkinsfile-runner/pom.xml
RUN cd /jenkinsfile-runner && mvn clean package
RUN mkdir /app && unzip /jenkinsfile-runner/target/war/jenkins.war -d /app/jenkins && \
rm -rf /app/jenkins/scripts /app/jenkins/jsbundles /app/jenkins/css /app/jenkins/images /app/jenkins/help /app/jenkins/WEB-INF/detached-plugins /app/jenkins/winstone.jar /app/jenkins/WEB-INF/jenkins-cli.jar /app/jenkins/WEB-INF/lib/jna-4.5.2.jar

####
# Production image
####
FROM adoptopenjdk:8u262-b10-jdk-hotspot

LABEL Description="This is a base image for a single-shot ci.jenkins.io demo" Vendor="Oleg Nenashev" Version="0.3"

# Packages
RUN apt-get update && apt-get install -y wget git curl sudo && rm -rf /var/lib/apt/lists/* && curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh

COPY --from=jfr-build /jenkinsfile-runner/target/appassembler /app
COPY --from=jfr-build /jenkinsfile-runner/target/plugins /usr/share/jenkins/ref/plugins
COPY --from=jenkins/jenkinsfile-runner:1.0-beta-15 /app/bin/jenkinsfile-runner-launcher /app/bin/jenkinsfile-runner-launcher
# /app/jenkins is a location of the WAR file. It can be empty in the current packaging
RUN mkdir /app/jenkins
## Plugins
COPY *-plugins.txt /usr/share/jenkins/ref/
RUN cd /app/jenkins && jar -cvf jenkins.war * && cat /usr/share/jenkins/ref/lib-plugins.txt >> /usr/share/jenkins/ref/runner-plugins.txt
RUN java -jar /app/bin/jenkins-plugin-manager.jar --war /app/jenkins/jenkins.war --plugin-file /usr/share/jenkins/ref/runner-plugins.txt && rm /app/jenkins/jenkins.war

VOLUME /usr/share/jenkins/ref/casc

COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
COPY init_scripts/src/main/groovy/* /usr/share/jenkins/ref/init.groovy.d/

ENV JENKINS_HOME="/usr/share/jenkins/ref/"
ENV JAVA_OPTS="-Djenkins.model.Jenkins.slaveAgentPort=50000 -Djenkins.model.Jenkins.slaveAgentPortEnforce=true -Dhudson.model.LoadStatistics.clock=1000"
ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/jenkins.yaml
COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
COPY init_scripts/src/main/groovy/* /usr/share/jenkins/ref/init.groovy.d/

ENTRYPOINT ["/app/bin/jenkinsfile-runner",\
"-w", "/app/jenkins",\
"-p", "/usr/share/jenkins/ref/plugins",\
"-f", "/workspace/Jenkinsfile"]
"-w", "/usr/share/jenkins/",\
"-p", "/usr/share/jenkins/ref/plugins"]

CMD ["-f /workspace/Jenkinsfile"]
14 changes: 0 additions & 14 deletions docker/jenkins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ jenkins:
scmCheckoutRetryCount: 0
myViewsTabBar: "standard"
viewsTabBar: "standard"
globalNodeProperties:
- envVars:
env:
- key: JFR_LOCAL_WORKSPACE
value: /workspace
- key: PIPELINE_LIBRARY_SKIP_WINDOWS
value: true
- key: PIPELINE_LIBRARY_USE_DEFAULT_MAVEN_REPO
value: true
tool:
git:
installations:
- home: "git"
name: "Default"
# Works around https://github.com/jenkinsci/jenkinsfile-runner/issues/359
groovy:
- file: "/usr/share/jenkins/ref/init.groovy.d/System.groovy"
Expand Down
2 changes: 2 additions & 0 deletions docker/lib-plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git:4.7.2
sshd:3.0.3
210 changes: 0 additions & 210 deletions docker/pom.xml

This file was deleted.

1 change: 1 addition & 0 deletions docker/runner-plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configuration-as-code-groovy:1.1
49 changes: 49 additions & 0 deletions jobs/scm/generic_example.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* groovylint-disable DuplicateMapLiteral, DuplicateStringLiteral, UnusedVariable */
@Library('jenkins-std-lib')

import org.dsty.scm.Generic

node() {
String cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)

// If you are not sure if you are dealing with git or svn then Generic is a good choice.
Generic scmClient = new Generic(this)

// These are the same options you would pass to the checkout step
// https://www.jenkins.io/doc/pipeline/steps/workflow-scm-step/

String defaultBranch = 'master'

Map options = [
changelog: false,
poll: false,
scm: [
$class: 'GitSCM',
branches: [[name: defaultBranch]],
extensions: [],
userRemoteConfigs: [[url: 'https://github.com/DontShaveTheYak/jenkins-std-lib.git']]
]
]

scmClient.checkout(options)

if (!env.GIT_BRANCH.contains(defaultBranch)) {
error("${env.GIT_BRANCH} should be equal to ${defaultBranch}.")
}

options.scm.branches = [[name: 'develop']]

dir('testing') {
scmClient.withCheckout(options) {
if (env.GIT_BRANCH.contains(defaultBranch)) {
error("${env.GIT_BRANCH} should not equal ${defaultBranch}.")
}
}
}

if (!env.GIT_BRANCH.contains(defaultBranch)) {
error("${env.GIT_BRANCH} should be equal to ${defaultBranch}.")
}

cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)
}
Loading

0 comments on commit d54b6c4

Please sign in to comment.