├── devJobDefinition.groovy
├── jenkins
├── Dockerfile
├── jobs
│ └── pipeline-updater
│ │ └── config.xml
└── resources
│ └── maven-settings.xml
├── docker-compose.yml
├── createDevJob.groovy
├── README.md
└── LICENSE.md
/devJobDefinition.groovy:
--------------------------------------------------------------------------------
1 | pipelineJob('devPipeline') {
2 | definition {
3 | cps {
4 | script(readFileFromWorkspace('Jenkinsfile'))
5 | sandbox()
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/jenkins/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM liatrio/jenkins-alpine:lts
2 | COPY jobs /usr/share/jenkins/ref/jobs/
3 | COPY resources/maven-settings.xml /usr/share/jenkins/ref/org.jenkinsci.plugins.configfiles.GlobalConfigFiles.xml
4 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | jenkins:
4 | build: ./jenkins
5 | volumes:
6 | - /var/run/docker.sock:/var/run/docker.sock
7 | - ../sample-pipeline-spring-petclinic:/pipeline-dev
8 | environment:
9 | JAVA_OPTS: -Djenkins.install.runSetupWizard=false
10 | ports:
11 | - "18080:8080"
12 | nexus:
13 | image: sonatype/nexus
14 | ports:
15 | - "18081:8081"
16 |
--------------------------------------------------------------------------------
/createDevJob.groovy:
--------------------------------------------------------------------------------
1 | def shellCommand = '''
2 | if [ ! -d /var/jenkins_home/jobs/devPipeline/ ]; then
3 | mkdir /var/jenkins_home/jobs/devPipeline/
4 | mkdir /var/jenkins_home/jobs/devPipeline/workspace/
5 | fi
6 | if [ -e /var/jenkins_home/jobs/devPipeline/workspace/* ]; then
7 | rm -r /var/jenkins_home/jobs/devPipeline/workspace/*
8 | fi
9 | if [[ ! -z "$(ls -A)" ]] ; then
10 | cp -r . /var/jenkins_home/jobs/devPipeline/workspace/
11 | fi
12 | '''
13 |
14 |
15 | job("pipeline-updater") {
16 | customWorkspace("/pipeline-dev")
17 | steps {
18 | dsl {
19 | text(readFileFromWorkspace('devJobDefinition.groovy'))
20 | removeAction('DELETE')
21 | }
22 | shell(shellCommand)
23 | }
24 | publishers {
25 | downstream('devPipeline', 'STABLE')
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pipeline-developer
2 |
3 | This is a jenkins server for developing pipelines locally without requiring git commits.
4 |
5 | ## Usage
6 |
7 | #### To use included jenkins container
8 | 1. Change the first half of line 7 from `../spring-petclinic` to the relative or absolute path of the pipeline directory to be worked on.
9 | 2. Run `docker-compose up`
10 | 3. Run the pipeline-updater job at `http://localhost:18080/job/pipeline-updater/`
11 | 4. Your pipeline should have run at `http://localhost:18080/job/devPipeline/`
12 |
13 | #### To use a different jenkins setup
14 | 1. Create a freestyle job.
15 | 2. Have it pull down this repo at `https://github.com/liatrio/pipeline-developer`
16 | 3. Add a "Process Job DSL Script" step and have it look on the filesystem for `createDevJob.groovy`
17 | 4. Add a volume to the jenkins container in the docker-compose that references your project so that jenkins can copy those files in.
18 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2018 GitHub Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/jenkins/jobs/pipeline-updater/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
7 | false
8 |
9 |
10 |
11 | true
12 | false
13 | false
14 | false
15 |
16 | false
17 | /pipeline-dev
18 |
19 |
20 | if [ ! -d "/var/jenkins_home/jobs/devPipeline/" ]; then
21 | mkdir /var/jenkins_home/jobs/devPipeline/
22 | mkdir /var/jenkins_home/jobs/devPipeline/workspace/
23 | fi
24 | if [ -e /var/jenkins_home/jobs/devPipeline/workspace/* ]; then
25 | rm -r /var/jenkins_home/jobs/devPipeline/workspace/*
26 | fi
27 | if [[ ! -z "$(ls -A)" ]] ; then
28 | cp -r . /var/jenkins_home/jobs/devPipeline/workspace/
29 | fi
30 |
31 |
32 | pipelineJob('devPipeline') {
33 | definition {
34 | cps {
35 | script(readFileFromWorkspace('Jenkinsfile'))
36 | sandbox()
37 | }
38 | }
39 | }
40 | true
41 | false
42 | false
43 | false
44 | false
45 | false
46 | DELETE
47 | IGNORE
48 | IGNORE
49 | JENKINS_ROOT
50 |
51 |
52 |
53 |
54 | devPipeline
55 |
56 | SUCCESS
57 | 0
58 | BLUE
59 | true
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/jenkins/resources/maven-settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | nexus
7 | nexus
8 |
9 | <?xml version="1.0" encoding="UTF-8"?>
10 | <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
11 | <mirrors>
12 | <mirror>
13 | <mirrorOf>central</mirrorOf>
14 | <url>http://nexus:8081/nexus/content/repositories/central/</url>
15 | <id>releases</id>
16 | </mirror>
17 | </mirrors>
18 | <servers>
19 | <server>
20 | <id>releases</id>
21 | <username>nexus</username>
22 | <password>admin123</password>
23 | </server>
24 | <server>
25 | <id>snapshots</id>
26 | <username>nexus</username>
27 | <password>admin123</password>
28 | </server>
29 | <server>
30 | <id>deployment</id>
31 | <username>admin</username>
32 | <password>admin123</password>
33 | </server>
34 | </servers>
35 | </settings>
36 | org.jenkinsci.plugins.configfiles.xml.XmlConfig
37 |
38 |
39 | nexus
40 | nexus
41 |
42 | <?xml version="1.0" encoding="UTF-8"?>
43 | <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44 | <servers>
45 | <server>
46 | <id>releases</id>
47 | <username>admin</username>
48 | <password>admin123</password>
49 | </server>
50 | <server>
51 | <id>snapshots</id>
52 | <username>admin</username>
53 | <password>admin123</password>
54 | </server>
55 | <server>
56 | <id>deployment</id>
57 | <username>admin</username>
58 | <password>admin123</password>
59 | </server>
60 | </servers>
61 | </settings>
62 | org.jenkinsci.plugins.configfiles.xml.XmlConfig
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------