Skip to content

Commit d54b6c4

Browse files
authored
Merge pull request #102 from DontShaveTheYak/develop
Release v0.8.0
2 parents 7f1e7d2 + 4c9ce1e commit d54b6c4

15 files changed

+493
-255
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- 'jobs/**'
1414
- 'src/**'
1515
- 'tests/**'
16+
- 'docker/**'
1617

1718
jobs:
1819
linting:

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ We recommend the following plugins:
4242
```
4343
* [AnsiColor](https://plugins.jenkins.io/ansicolor/) - To get color coded log messages from our logging package.
4444

45+
The required plugins and versions to enable complete library functionality can be found in [lib-plugins.txt](./docker/lib-plugins.txt).
46+
4547
*Note: Individual library functions may have their own requirements. See the [docs][doc-url]*
4648

4749
### Usage

docker/Dockerfile

+12-30
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
1-
FROM jenkins/jenkinsfile-runner:build-mvncache as jfr-mvncache
1+
FROM jenkins/jenkinsfile-runner:latest
22

3-
###
4-
# Build stage
5-
###
6-
FROM maven:3.5.4 as jfr-build
7-
ENV MAVEN_OPTS=-Dmaven.repo.local=/mavenrepo
8-
COPY --from=jfr-mvncache /mavenrepo /mavenrepo
9-
ADD pom.xml /jenkinsfile-runner/pom.xml
10-
RUN cd /jenkinsfile-runner && mvn clean package
11-
RUN mkdir /app && unzip /jenkinsfile-runner/target/war/jenkins.war -d /app/jenkins && \
12-
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
13-
14-
####
15-
# Production image
16-
####
17-
FROM adoptopenjdk:8u262-b10-jdk-hotspot
18-
19-
LABEL Description="This is a base image for a single-shot ci.jenkins.io demo" Vendor="Oleg Nenashev" Version="0.3"
20-
21-
# Packages
223
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
234

24-
COPY --from=jfr-build /jenkinsfile-runner/target/appassembler /app
25-
COPY --from=jfr-build /jenkinsfile-runner/target/plugins /usr/share/jenkins/ref/plugins
26-
COPY --from=jenkins/jenkinsfile-runner:1.0-beta-15 /app/bin/jenkinsfile-runner-launcher /app/bin/jenkinsfile-runner-launcher
27-
# /app/jenkins is a location of the WAR file. It can be empty in the current packaging
28-
RUN mkdir /app/jenkins
5+
## Plugins
6+
COPY *-plugins.txt /usr/share/jenkins/ref/
7+
RUN cd /app/jenkins && jar -cvf jenkins.war * && cat /usr/share/jenkins/ref/lib-plugins.txt >> /usr/share/jenkins/ref/runner-plugins.txt
8+
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
299

3010
VOLUME /usr/share/jenkins/ref/casc
3111

12+
COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
13+
COPY init_scripts/src/main/groovy/* /usr/share/jenkins/ref/init.groovy.d/
14+
3215
ENV JENKINS_HOME="/usr/share/jenkins/ref/"
3316
ENV JAVA_OPTS="-Djenkins.model.Jenkins.slaveAgentPort=50000 -Djenkins.model.Jenkins.slaveAgentPortEnforce=true -Dhudson.model.LoadStatistics.clock=1000"
3417
ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/jenkins.yaml
35-
COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
36-
COPY init_scripts/src/main/groovy/* /usr/share/jenkins/ref/init.groovy.d/
3718

3819
ENTRYPOINT ["/app/bin/jenkinsfile-runner",\
39-
"-w", "/app/jenkins",\
40-
"-p", "/usr/share/jenkins/ref/plugins",\
41-
"-f", "/workspace/Jenkinsfile"]
20+
"-w", "/usr/share/jenkins/",\
21+
"-p", "/usr/share/jenkins/ref/plugins"]
22+
23+
CMD ["-f /workspace/Jenkinsfile"]

docker/jenkins.yaml

-14
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@ jenkins:
55
scmCheckoutRetryCount: 0
66
myViewsTabBar: "standard"
77
viewsTabBar: "standard"
8-
globalNodeProperties:
9-
- envVars:
10-
env:
11-
- key: JFR_LOCAL_WORKSPACE
12-
value: /workspace
13-
- key: PIPELINE_LIBRARY_SKIP_WINDOWS
14-
value: true
15-
- key: PIPELINE_LIBRARY_USE_DEFAULT_MAVEN_REPO
16-
value: true
17-
tool:
18-
git:
19-
installations:
20-
- home: "git"
21-
name: "Default"
228
# Works around https://github.com/jenkinsci/jenkinsfile-runner/issues/359
239
groovy:
2410
- file: "/usr/share/jenkins/ref/init.groovy.d/System.groovy"

docker/lib-plugins.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
git:4.7.2
2+
sshd:3.0.3

docker/pom.xml

-210
This file was deleted.

docker/runner-plugins.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
configuration-as-code-groovy:1.1

jobs/scm/generic_example.groovy

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* groovylint-disable DuplicateMapLiteral, DuplicateStringLiteral, UnusedVariable */
2+
@Library('jenkins-std-lib')
3+
4+
import org.dsty.scm.Generic
5+
6+
node() {
7+
String cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)
8+
9+
// If you are not sure if you are dealing with git or svn then Generic is a good choice.
10+
Generic scmClient = new Generic(this)
11+
12+
// These are the same options you would pass to the checkout step
13+
// https://www.jenkins.io/doc/pipeline/steps/workflow-scm-step/
14+
15+
String defaultBranch = 'master'
16+
17+
Map options = [
18+
changelog: false,
19+
poll: false,
20+
scm: [
21+
$class: 'GitSCM',
22+
branches: [[name: defaultBranch]],
23+
extensions: [],
24+
userRemoteConfigs: [[url: 'https://github.com/DontShaveTheYak/jenkins-std-lib.git']]
25+
]
26+
]
27+
28+
scmClient.checkout(options)
29+
30+
if (!env.GIT_BRANCH.contains(defaultBranch)) {
31+
error("${env.GIT_BRANCH} should be equal to ${defaultBranch}.")
32+
}
33+
34+
options.scm.branches = [[name: 'develop']]
35+
36+
dir('testing') {
37+
scmClient.withCheckout(options) {
38+
if (env.GIT_BRANCH.contains(defaultBranch)) {
39+
error("${env.GIT_BRANCH} should not equal ${defaultBranch}.")
40+
}
41+
}
42+
}
43+
44+
if (!env.GIT_BRANCH.contains(defaultBranch)) {
45+
error("${env.GIT_BRANCH} should be equal to ${defaultBranch}.")
46+
}
47+
48+
cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)
49+
}

0 commit comments

Comments
 (0)