├── .gitattributes ├── .gitignore ├── DOCKER_COMMANDS.md ├── KAFKA_ZOOKEEPER_README.md ├── LICENSE ├── README.md ├── docker-compose-dev.yml ├── docker-compose.yml ├── docs ├── event-driven-microservices-platform.key └── overview.png ├── edmp-monitoring ├── Dockerfile └── application.properties ├── jenkins ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── config │ ├── config.xml │ ├── credentials.xml │ ├── hudson.plugins.groovy.Groovy.xml │ ├── hudson.tasks.Maven.xml │ ├── maven-global-settings-files.xml │ ├── settings.xml │ └── ssh-keys │ │ ├── cd-demo │ │ └── cd-demo.pub ├── jobs │ └── admin-edmp-seed-job.xml ├── plugins.txt └── seedjobs │ └── edmpSeedJob.groovy ├── nexus ├── Dockerfile ├── README.md └── nexus.xml └── sonar ├── Dockerfile ├── README.md └── run.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/dealing-with-line-endings/ 2 | 3 | # Set the default behavior, in case people don't have core.autocrlf set. 4 | * text=auto 5 | 6 | # Explicitly declare text files you want to always be normalized and converted 7 | # to native line endings on checkout. 8 | *.c text 9 | *.h text 10 | 11 | # Declare files that will always have CRLF line endings on checkout. 12 | *.sln text eol=crlf 13 | 14 | # Preserve Unix line endings on those files (used inside the Linux VM) 15 | jenkins/plugins.txt text eol=lf 16 | sonar/run.sh text eol=lf 17 | 18 | # Denote all files that are truly binary and should not be modified. 19 | *.png binary 20 | *.jpg binary 21 | 22 | # EOF 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.project 3 | -------------------------------------------------------------------------------- /DOCKER_COMMANDS.md: -------------------------------------------------------------------------------- 1 | ## Useful Docker commands 2 | 3 | ### Create Docker Network 4 | 5 | ``` 6 | docker network create --driver bridge prodnetwork 7 | ``` 8 | 9 | ### Compile, Build and Run Docker Container - edmp-config-server 10 | 11 | ``` 12 | cd edmp-config-server 13 | mvn clean install 14 | docker build -t edmp-config-server . 15 | docker rm $(docker ps -a -q --filter="name=edmp-config-server") 16 | docker run --name="edmp-config-server" --net=prodnetwork -p 18888:8888 edmp-config-server 17 | ``` 18 | 19 | ### Compile, Build and Run Docker Container - edmp-monitoring 20 | 21 | ``` 22 | cd edmp-monitoring 23 | mvn clean install 24 | docker build -t edmp-monitoring . 25 | docker rm $(docker ps -a -q --filter="name=edmp-monitoring") 26 | docker run --name="edmp-monitoring" --net=prodnetwork -p 10001:8080 edmp-monitoring 27 | ``` 28 | 29 | ## Docker Utility Commands 30 | 31 | ### Connect to running Docker Container 32 | 33 | ``` 34 | docker exec -i -t ${CONTAINER ID} bash 35 | ``` 36 | -------------------------------------------------------------------------------- /KAFKA_ZOOKEEPER_README.md: -------------------------------------------------------------------------------- 1 | # Admin Commands 2 | 3 | https://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands 4 | 5 | ## Verify that Zookeeper is running 6 | 7 | ``` 8 | echo stat | nc 192.168.99.100 2181 9 | ``` 10 | 11 | Result 12 | ``` 13 | Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT 14 | Clients: 15 | /172.17.0.4:42600[1](queued=0,recved=215,sent=218) 16 | /192.168.99.1:57761[0](queued=0,recved=1,sent=0) 17 | 18 | Latency min/avg/max: 0/0/52 19 | Received: 225 20 | Sent: 227 21 | Connections: 2 22 | Outstanding: 0 23 | Zxid: 0x23 24 | Mode: standalone 25 | Node count: 24 26 | ``` 27 | 28 | ``` 29 | echo mntr | nc 192.168.99.100 2181 30 | ``` 31 | 32 | Result 33 | 34 | ``` 35 | zk_version 3.4.6-1569965, built on 02/20/2014 09:09 GMT 36 | zk_avg_latency 0 37 | zk_max_latency 52 38 | zk_min_latency 0 39 | zk_packets_received 271 40 | zk_packets_sent 273 41 | zk_num_alive_connections 2 42 | zk_outstanding_requests 0 43 | zk_server_state standalone 44 | zk_znode_count 24 45 | zk_watch_count 12 46 | zk_ephemerals_count 2 47 | zk_approximate_data_size 713 48 | zk_open_file_descriptor_count 29 49 | zk_max_file_descriptor_count 1048576 50 | ``` 51 | 52 | ## Get Zookeeper Environment Information 53 | 54 | ``` 55 | echo envi | nc 192.168.99.100 2181 56 | ``` 57 | 58 | Result 59 | 60 | ``` 61 | Environment: 62 | zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT 63 | host.name=7167a11e1223 64 | java.version=1.7.0_65 65 | java.vendor=Oracle Corporation 66 | java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre 67 | java.class.path=/opt/zookeeper-3.4.6/bin/../build/classes:/opt/zookeeper-3.4.6/bin/../build/lib/*.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/opt/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/opt/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.6/bin/../conf: 68 | java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib 69 | java.io.tmpdir=/tmp 70 | java.compiler= 71 | os.name=Linux 72 | os.arch=amd64 73 | os.version=4.1.17-boot2docker 74 | user.name=root 75 | user.home=/root 76 | user.dir=/opt/zookeeper-3.4.6 77 | ``` 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 codecentric 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Goal 2 | Playing around with Event Driven Architectures is hard! The goal of this project is to simplify playing around with EDAs - and to use technologies, best practices and approaches that may easily be extrapolated to a production-ready state. 3 | 4 | ## So, what's in here? 5 | Everything is based on Docker, so basically we boot a lot of stuff on startup via docker-compose. Let's have a deeper look. There is 6 | ### Kafka and Zookeeper 7 | If you do EDA the messaging way you need a broker. A broker that's able to replay messages, that has persistent messages, a broker that's scalable and highly available - in short: you need Kafka. 8 | ### Jenkins, Sonar and Nexus 9 | We included a build and deployment pipeline. Jobs are added to Jenkins via Job DSL, which creates CI-, Sonar- and Docker-Build-and-Deployment-Jobs for each microservice specified in one simple configuration file (https://github.com/codecentric/event-driven-microservices-platform-config/blob/master/edmp-project-configuration.json). That way you just create a Maven-based microservice in a new Github repository, add it to the configuration file above and our Jenkins-Job-DSL-Seedjob will pick it up, create jobs for it and deploy it on every change. 10 | ### Spring Boot Admin 11 | If the microservice happens to be a Spring Boot based microservice, it can be automatically registered in our always running Spring Boot Admin instance for easy monitoring. 12 | ### Spring Cloud Config Server 13 | Spring Cloud Config exposes a Github repository as a central place for configuration data, and that data can be consumed via a REST API. Of course, if you're using Spring Boot, there's a convenient way to consume this data via a special Spring Boot starter. 14 | ### Sample apps 15 | There are three sample apps to get you started - two Spring Cloud Stream applications that write / read to / from Kafka, and one standalone application that uses its own private Redis. These sample apps are not started by docker-compose but by automatically generated Jenkins jobs. 16 | 17 | ## Project Overview 18 | 19 | The following diagram gives a quick overview of the different tools we are using in this project. 20 | 21 | ![Overview](https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform/master/docs/overview.png) 22 | 23 | What are the tools used for? 24 | 25 | * Jenkins 26 | * Job DSL generates Build & Deploy Jobs for all Microservices 27 | * Build & Deploys Microservices 28 | * Builds / Starts / Stops Docker Container 29 | * Nexus 30 | * Stores Build Artifacts 31 | * SonarQube 32 | * Stores Static Code Analysis Results 33 | * Kafka / Zookeeper Server 34 | * Distributed Messaging System / Coordination System 35 | * Microservices Docker Container 36 | * Sample Message Driven Microservices 37 | 38 | ## Related Projects 39 | 40 | - https://github.com/codecentric/event-driven-microservices-platform-config 41 | - https://github.com/codecentric/edmp-sample-app 42 | - https://github.com/codecentric/edmp-sample-stream-source 43 | - https://github.com/codecentric/edmp-sample-stream-sink 44 | 45 | ## Prerequisites (Mac) 46 | 47 | You should have Docker Toolbox installed, see https://www.docker.com/toolbox 48 | 49 | I am using docker-compose to start several docker container at once. 50 | Since all containers run in a single VM (virtualbox), this VM needs enough memory. 51 | 52 | ### Step 0 - Check Docker Machine version 53 | 54 | Ensure that you are using version 0.3.0 or greater of `docker-machine` 55 | 56 | ``` 57 | $ docker-machine version 58 | docker-machine version 0.6.0, build e27fb87 59 | ``` 60 | 61 | ### Step 1 - Start Docker Machine 62 | 63 | Start the machine, using the `--virtualbox-memory` option to increase it’s memory. I also recommend using the `--virtualbox-disk-size` option to increate it's disk size. I use 6000 MB to accommodate all the docker images and 40000 MB to allow for enough disk space. 64 | 65 | ``` 66 | $ docker-machine create -d virtualbox --virtualbox-memory "6000" --virtualbox-disk-size "40000" default 67 | Running pre-create checks... 68 | Creating machine... 69 | (default) Creating VirtualBox VM... 70 | (default) Creating SSH key... 71 | (default) Starting VM... 72 | Waiting for machine to be running, this may take a few minutes... 73 | Machine is running, waiting for SSH to be available... 74 | Detecting operating system of created instance... 75 | Detecting the provisioner... 76 | Provisioning with boot2docker... 77 | Copying certs to the local machine directory... 78 | Copying certs to the remote machine... 79 | Setting Docker configuration on the remote daemon... 80 | Checking connection to Docker... 81 | Docker is up and running! 82 | To see how to connect Docker to this machine, run: docker-machine env default 83 | ``` 84 | 85 | ### Step 2 - Set Docker Machine Connection 86 | 87 | Configure shell environment to connect to your new Docker instance 88 | 89 | ``` 90 | $ eval "$(docker-machine env default)" 91 | ``` 92 | 93 | ## Getting started 94 | 95 | To get all docker containers up and running use: 96 | 97 | ``` 98 | $ git clone git@github.com:codecentric/event-driven-microservices-platform.git 99 | $ cd event-driven-microservices-platform 100 | $ docker-compose up 101 | ``` 102 | 103 | If you want to use your own Github repository for the EDMP configuration file and the Spring Cloud Config Server property files you have to change two lines in the docker-compose.yml. First, change the CONFIG_REPO environment variable for the edmp-config-server according to your needs: 104 | ``` 105 | edmp-config-server: 106 | image: codecentric/edmp-config-server 107 | ports: 108 | - "18888:8888" 109 | networks: 110 | - prodnetwork 111 | environment: 112 | CONFIG_REPO: "https://github.com/codecentric/event-driven-microservices-platform-config.git" 113 | ``` 114 | Then, change the EDMP_CONFIG_URL environment variable for jenkins according to your needs: 115 | ``` 116 | jenkins: 117 | image: codecentric/edmp-jenkins:0.1 118 | ports: 119 | - "18080:8080" 120 | links: 121 | - nexus:nexus 122 | - sonar:sonar 123 | volumes: 124 | - /var/run/docker.sock:/var/run/docker.sock 125 | - /usr/local/bin/docker:/usr/bin/docker 126 | environment: 127 | EDMP_CONFIG_URL: "https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform-config/master/edmp-project-configuration.json" 128 | ``` 129 | 130 | 131 | For local development build the local images first and start them using: 132 | 133 | ``` 134 | $ docker-compose -f docker-compose-dev.yml build 135 | $ docker-compose -f docker-compose-dev.yml up 136 | ``` 137 | 138 | ## Tools 139 | 140 | | *Tool* | *Link* | *Credentials* | 141 | | ------------- | ------------- | ------------- | 142 | | Jenkins | http://${docker-machine ip default}:18080/ | no login required | 143 | | SonarQube | http://${docker-machine ip default}:19000/ | admin/admin | 144 | | Nexus | http://${docker-machine ip default}:18081/nexus | admin/admin123 | 145 | | Docker Registry | http://${docker-machine ip default}:5000/ | | 146 | | Spring Boot Admin | http://${docker-machine ip default}:10001/ | | 147 | | Spring Cloud Config Server | http://${docker-machine ip default}:18888/${applicationname}/master | | 148 | | Kafka Manager | http://${docker-machine ip default}:29000/ | | 149 | 150 | ## FAQ 151 | 152 | ### Having problems downloading docker images? 153 | 154 | **Error:** Network timed out while trying to connect to https://index.docker.io/ 155 | 156 | **Solution** 157 | 158 | ``` 159 | # Add nameserver to DNS (probably need to do "sudo su" first) 160 | echo "nameserver 8.8.8.8" > /etc/resolv.conf 161 | 162 | # Restart the environment 163 | $ docker-machine restart default 164 | 165 | # Refresh your environment settings 166 | $ eval $(docker-machine env default) 167 | ``` 168 | I also needed to do this inside the docker-machine: 169 | ``` 170 | $ docker-machine ssh default 171 | $ echo "nameserver 8.8.8.8" > /etc/resolv.conf 172 | ``` 173 | 174 | 175 | ### No Internet Connection from Docker Container 176 | 177 | ``` 178 | # Login to Docker VM 179 | $ docker-machine ssh default 180 | 181 | # Run DHCP client 182 | $ sudo udhcpc 183 | 184 | # Restart docker process 185 | $ sudo /etc/init.d/docker restart 186 | ``` 187 | -------------------------------------------------------------------------------- /docker-compose-dev.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | networks: 4 | prodnetwork: 5 | driver: bridge 6 | 7 | volumes: 8 | registry-stuff: 9 | driver: local 10 | 11 | services: 12 | edmp-monitoring: 13 | build: ./edmp-monitoring 14 | ports: 15 | - "10001:8080" 16 | networks: 17 | - prodnetwork 18 | kafka: 19 | image: spotify/kafka 20 | ports: 21 | - "2181:2181" 22 | - "9092:9092" 23 | - "7209:7209" 24 | environment: 25 | JMX_PORT: 7209 26 | ADVERTISED_HOST: 192.168.99.100 27 | ADVERTISED_PORT: 9092 28 | networks: 29 | - prodnetwork 30 | kafka-manager: 31 | image: sheepkiller/kafka-manager 32 | ports: 33 | - "29000:9000" 34 | environment: 35 | ZK_HOSTS: zk:2181 36 | networks: 37 | - prodnetwork 38 | links: 39 | - kafka:zk 40 | depends_on: 41 | - kafka 42 | 43 | nexus: 44 | build: ./nexus 45 | ports: 46 | - "18081:8081" 47 | 48 | jenkins: 49 | build: ./jenkins 50 | ports: 51 | - "18080:8080" 52 | links: 53 | - nexus:nexus 54 | - sonar:sonar 55 | volumes: 56 | - /var/run/docker.sock:/var/run/docker.sock 57 | - /usr/local/bin/docker:/usr/bin/docker 58 | environment: 59 | EDMP_CONFIG_URL: "https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform-config/master/edmp-project-configuration.json" 60 | 61 | registry: 62 | image: registry 63 | environment: 64 | - STORAGE_PATH=/registry 65 | volumes: 66 | - registry-stuff:/registry 67 | ports: 68 | - "5000:5000" 69 | 70 | sonar: 71 | build: ./sonar 72 | ports: 73 | - "19000:9000" 74 | environment: 75 | - SONARQUBE_JDBC_URL=jdbc:postgresql://sonardb:5432/sonar 76 | depends_on: 77 | - sonardb 78 | sonardb: 79 | image: postgres 80 | ports: 81 | - "5432:5432" 82 | environment: 83 | - POSTGRES_USER=sonar 84 | - POSTGRES_PASSWORD=sonar 85 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | networks: 4 | prodnetwork: 5 | driver: bridge 6 | 7 | volumes: 8 | registry-stuff: 9 | driver: local 10 | 11 | services: 12 | edmp-monitoring: 13 | image: codecentric/edmp-monitoring 14 | ports: 15 | - "10001:8080" 16 | networks: 17 | - prodnetwork 18 | kafka: 19 | image: spotify/kafka 20 | ports: 21 | - "2181:2181" 22 | - "9092:9092" 23 | - "7209:7209" 24 | environment: 25 | JMX_PORT: 7209 26 | ADVERTISED_HOST: 192.168.99.100 27 | ADVERTISED_PORT: 9092 28 | networks: 29 | - prodnetwork 30 | kafka-manager: 31 | image: sheepkiller/kafka-manager 32 | ports: 33 | - "29000:9000" 34 | environment: 35 | ZK_HOSTS: zk:2181 36 | networks: 37 | - prodnetwork 38 | links: 39 | - kafka:zk 40 | depends_on: 41 | - kafka 42 | 43 | nexus: 44 | image: codecentric/edmp-nexus:0.1 45 | ports: 46 | - "18081:8081" 47 | 48 | jenkins: 49 | image: codecentric/edmp-jenkins:0.1 50 | ports: 51 | - "18080:8080" 52 | links: 53 | - nexus:nexus 54 | - sonar:sonar 55 | volumes: 56 | - /var/run/docker.sock:/var/run/docker.sock 57 | - /usr/local/bin/docker:/usr/bin/docker 58 | environment: 59 | EDMP_CONFIG_URL: "https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform-config/master/edmp-project-configuration.json" 60 | 61 | registry: 62 | image: registry 63 | environment: 64 | - STORAGE_PATH=/registry 65 | volumes: 66 | - registry-stuff:/registry 67 | ports: 68 | - "5000:5000" 69 | 70 | sonar: 71 | image: codecentric/edmp-sonar:0.1 72 | ports: 73 | - "19000:9000" 74 | environment: 75 | - SONARQUBE_JDBC_URL=jdbc:postgresql://sonardb:5432/sonar 76 | depends_on: 77 | - sonardb 78 | sonardb: 79 | image: postgres 80 | ports: 81 | - "5432:5432" 82 | environment: 83 | - POSTGRES_USER=sonar 84 | - POSTGRES_PASSWORD=sonar 85 | -------------------------------------------------------------------------------- /docs/event-driven-microservices-platform.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform/b2896e5b1a351a77531065fcb53ca4aa87ca601f/docs/event-driven-microservices-platform.key -------------------------------------------------------------------------------- /docs/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecentric/event-driven-microservices-platform/b2896e5b1a351a77531065fcb53ca4aa87ca601f/docs/overview.png -------------------------------------------------------------------------------- /edmp-monitoring/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8-jdk 2 | MAINTAINER Tobias Flohre tobias.flohre@codecentric.de 3 | 4 | ENV SBA_VERSION 1.3.3 5 | EXPOSE 8080 6 | WORKDIR /opt/edmp-monitoring/ 7 | COPY application.properties /opt/edmp-monitoring/application.properties 8 | RUN curl -LO http://search.maven.org/remotecontent?filepath=de/codecentric/spring-boot-admin-sample/${SBA_VERSION}/spring-boot-admin-sample-${SBA_VERSION}.jar 9 | CMD java -Djava.security.egd=file:/dev/./urandom -jar spring-boot-admin-sample-${SBA_VERSION}.jar 10 | -------------------------------------------------------------------------------- /edmp-monitoring/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=edmp-monitoring 2 | -------------------------------------------------------------------------------- /jenkins/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /jenkins/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jenkins:1.642.1 2 | 3 | MAINTAINER Marcel Birkner 4 | 5 | USER root 6 | RUN apt-get update \ 7 | && apt-get install -y sudo \ 8 | && rm -rf /var/lib/apt/lists/* 9 | RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers 10 | USER jenkins 11 | 12 | COPY plugins.txt /var/jenkins_home/plugins.txt 13 | RUN /usr/local/bin/plugins.sh /var/jenkins_home/plugins.txt 14 | 15 | # Adding default Jenkins Jobs 16 | COPY jobs/admin-edmp-seed-job.xml /usr/share/jenkins/ref/jobs/admin-edmp-seed-job/config.xml 17 | 18 | ############################################ 19 | # Configure Jenkins 20 | ############################################ 21 | # Jenkins settings 22 | COPY config/config.xml /usr/share/jenkins/ref/config.xml 23 | 24 | # Jenkins Settings, i.e. Maven, Groovy, ... 25 | COPY config/hudson.tasks.Maven.xml /usr/share/jenkins/ref/hudson.tasks.Maven.xml 26 | COPY config/hudson.plugins.groovy.Groovy.xml /usr/share/jenkins/ref/hudson.plugins.groovy.Groovy.xml 27 | COPY config/maven-global-settings-files.xml /usr/share/jenkins/ref/maven-global-settings-files.xml 28 | 29 | # SSH Keys & Credentials 30 | COPY config/credentials.xml /usr/share/jenkins/ref/credentials.xml 31 | COPY config/ssh-keys/cd-demo /usr/share/jenkins/ref/.ssh/id_rsa 32 | COPY config/ssh-keys/cd-demo.pub /usr/share/jenkins/ref/.ssh/id_rsa.pub 33 | -------------------------------------------------------------------------------- /jenkins/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Marcel Birkner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /jenkins/README.md: -------------------------------------------------------------------------------- 1 | ## Jenkins Docker Container 2 | 3 | Usage: 4 | ``` 5 | $ docker build -t jenkins . 6 | $ docker run -d -p=8080:8080 jenkins 7 | ``` 8 | 9 | Once Jenkins is up and running go to http://192.168.59.103:8080 10 | 11 | ### Links 12 | 13 | - Job DSL API https://jenkinsci.github.io/job-dsl-plugin/ 14 | -------------------------------------------------------------------------------- /jenkins/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OldData 5 | jenkins.diagnostics.SecurityIsOffMonitor 6 | 7 | 1.642.1 8 | 4 9 | NORMAL 10 | true 11 | 12 | 13 | false 14 | 15 | ${ITEM_ROOTDIR}/workspace 16 | ${ITEM_ROOTDIR}/builds 17 | 18 | 19 | JDK 8 20 | /usr/lib/jvm/java-8-openjdk-amd64 21 | 22 | 23 | 24 | 25 | 26 | 27 | 5 28 | 0 29 | 30 | 31 | 32 | All 33 | false 34 | false 35 | 36 | 37 | 38 | All 39 | 50000 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /jenkins/config/credentials.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | GLOBAL 11 | nexus 12 | Nexus Admin User 13 | admin 14 | 5EyCZAqQFDCQH2wg8s5K77WPVYSj3Xha5tunegtXnCk= 15 | 16 | 17 | GLOBAL 18 | 50ff7d29-65eb-4396-9476-f823734a25af 19 | 20 | admin 21 | lMNOKgKXWKJwk6oT/wZiww== 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /jenkins/config/hudson.plugins.groovy.Groovy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0 5 | 6 | false 7 | 8 | 9 | 10 | Groovy 2.4.3 11 | /usr/share/groovy-2.4.3 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jenkins/config/hudson.tasks.Maven.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Maven 3.3.3 6 | 7 | 8 | 9 | 10 | 3.3.3 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /jenkins/config/maven-global-settings-files.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1435422191538 6 | 7 | org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1435422191538 8 | MyGlobalSettings 9 | global settings 10 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> 11 | <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> 12 | <mirrors> 13 | <mirror> 14 | <!--This sends everything else to /public --> 15 | <id>nexus</id> 16 | <mirrorOf>*</mirrorOf> 17 | <url>http://nexus:8081/nexus/content/groups/public</url> 18 | </mirror> 19 | </mirrors> 20 | <servers> 21 | <server> 22 | <id>nexus-release-repository</id> 23 | <username>admin</username> 24 | <password>admin123</password> 25 | </server> 26 | </servers> 27 | <profiles> 28 | <profile> 29 | <id>sonar</id> 30 | <activation> 31 | <activeByDefault>true</activeByDefault> 32 | </activation> 33 | <properties> 34 | <sonar.jdbc.url> 35 | jdbc:postgresql://sonar:5432/sonar 36 | </sonar.jdbc.url> 37 | <sonar.jdbc.username>sonar</sonar.jdbc.username> 38 | <sonar.jdbc.password>sonar</sonar.jdbc.password> 39 | <!-- Optional URL to server. Default value is http://localhost:9000 --> 40 | <sonar.host.url>http://sonar:9000</sonar.host.url> 41 | </properties> 42 | </profile> 43 | <profile> 44 | <id>nexus</id> 45 | <!--Enable snapshots for the built in central repo to direct --> 46 | <!--all requests to nexus via the mirror --> 47 | <repositories> 48 | <repository> 49 | <id>central</id> 50 | <url>http://central</url> 51 | <releases><enabled>true</enabled></releases> 52 | <snapshots><enabled>true</enabled></snapshots> 53 | </repository> 54 | </repositories> 55 | <pluginRepositories> 56 | <pluginRepository> 57 | <id>central</id> 58 | <url>http://central</url> 59 | <releases><enabled>true</enabled></releases> 60 | <snapshots><enabled>true</enabled></snapshots> 61 | </pluginRepository> 62 | </pluginRepositories> 63 | </profile> 64 | </profiles> 65 | <activeProfiles> 66 | <!--make the profile active all the time --> 67 | <activeProfile>nexus</activeProfile> 68 | </activeProfiles> 69 | </settings> 70 | 71 | 72 | true 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /jenkins/config/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | nexus-release-repository 7 | admin 8 | admin123 9 | 10 | 11 | 12 | 13 | 14 | 15 | nexus 16 | * 17 | http://nexus:8081/nexus/content/groups/public 18 | 19 | 20 | 21 | 22 | 23 | sonar 24 | 25 | true 26 | 27 | 28 | 36 | 37 | http://sonar:9000 38 | 39 | 40 | 41 | nexus 42 | 43 | 44 | 45 | 46 | central 47 | http://central 48 | true 49 | true 50 | 51 | 52 | 53 | 54 | central 55 | http://central 56 | true 57 | true 58 | 59 | 60 | 61 | 62 | 63 | 64 | nexus 65 | 66 | 67 | -------------------------------------------------------------------------------- /jenkins/config/ssh-keys/cd-demo: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | 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 38 | 8BRWEwtaOrfuOpnolw1Kt6c0JxF2ks4OlkzMk1QZsvS9zc506e5q1Du5IS4K3RHS 39 | FhVQXfBh4MERGwc7iZPgABNmufi6q8z02aiNZTtylIxcSrHkVmZ2OyNX2whmzd8O 40 | WqSioQKCAQEArdiGPB20ZZtayAUZRH3K+SAf7fHulGpoyWLaDc3AuNFG4L3ISSD+ 41 | 5EnNKmHlJgsAx1/bivmcas/9eaEBg3gEMgk+kJAH7i2KxRxmlN7DMbzmbMNEaGNk 42 | xWaZ4LU+h5AZBRTrZcyP7/TJBLuua2hUnbVg9YhslpdJLDNiyOHbwNqsuSXf+WPp 43 | 0GYB8yAQus1ItyqUEV2ao/6aJFZMIRDe8iRSQLd4E4yzeCZB+0rqTirWLE9slH/u 44 | JMDb/XxK9ZaLkODxsuXivIcNVil98D+Sh5qAKcBJbYPeMsfSVMzbZcWCzs04NO7d 45 | TcJrYnrwspLDtCeuaog5TppQS7J2oKs0mQKCAQBeSZKl95rcYFpbaDbpnMcyilkm 46 | BjH5eOF96eL6ISyuKzyeucWGsA8wNJ0kMYTcDO/0EYaDkF2k1SYPBMhvIp/njulZ 47 | nM/oli9drT9L0Ygymjl7XhKcIIc4T756wLHec3bngCkb5yPFLbndDSucUXfk+wdJ 48 | MbTsAlx9FJ2Nwv6No3bDG217ez38C13PjdR0Vijzc3WFUnj86dAIatcz7RJjrFOV 49 | Gy8VZDd8Fh+PC0FoA3t9YObpgbZoSslZl/7i9pMjq+ONfuQKsasWJIAOQJyjqU/M 50 | WWoElOsO0pHOmrQM1LeGAoPTqYML5HmCq4hbgNMt30P0ctfPjsfQO5y14o0j 51 | -----END RSA PRIVATE KEY----- 52 | -------------------------------------------------------------------------------- /jenkins/config/ssh-keys/cd-demo.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDJOvFnDlHcaExaM8DnVHO1V72F0S6JY9cr/COgGNqIyC+BzUxPaXGO8RpdzXG+xk8angygAr13Z0N3uup0bWNeHgWhaRhrkm2Mk8F3Bq8i+IVJqckyS3waxCfMcZYV5nQ5dAyeU18hbbQ36MIuS9JzqrFyBi2Zn1/pJVrTB3vNCE6rkQBqENQN+MMRfn9s8EGO4o6WrHtt8H0A3HxCJ1hDjLAKlUqA51uFDTSi5qa7EFvjBWPcn2gA09fDbbVztUxLfPAWllOL6ZjpGwa0lLdYR+Fbxbv6wxypz33xEs3Wpj+08bkep3QX2wJbcw7xvsrMmJ6UFn3Tmv1szYx41bbtNdLflRFbjVVCuwjcl/2ic+e7Tp7KxbGDfo7L5n4e/NLt0WBH8v1JUAh25Beu/Hua7Ozh1G2GK/1+HOj5tqF5yrarhEJ++A5+Si5tUieQqbGlvJ4l0HGj1ueJ6pLUZqMEEAIdHiF/oyyA+cLmoaR083CcTeZT2jHN6dw22mlCufLXcLoHij5vmSSy1NVezEfFonWqUA5UOWellnKMGyn9vYkR8Tma2tEd27p/SwILf19BIkVj7yDsJHDMJOq01vpNdPG3diHg7a4iF4aA5nzr2XaQhmm2s26VZLCaUzQVCwvZkkPK438wnqUrFEg2h8TM1PCeOjyfTMn0Y/e5wArPQQ== cd-demo@email.com 2 | -------------------------------------------------------------------------------- /jenkins/jobs/admin-edmp-seed-job.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -1 7 | 10 8 | -1 9 | -1 10 | 11 | false 12 | 13 | 14 | https://github.com/codecentric/event-driven-microservices-platform/ 15 | 16 | 17 | false 18 | false 19 | 20 | 21 | 22 | 2 23 | 24 | 25 | https://github.com/codecentric/event-driven-microservices-platform.git 26 | 27 | 28 | 29 | 30 | */master 31 | 32 | 33 | false 34 | 35 | 36 | 37 | true 38 | false 39 | false 40 | false 41 | 42 | 43 | H/5 * * * * 44 | 45 | 46 | false 47 | 48 | 49 | jenkins/seedjobs/edmpSeedJob.groovy 50 | false 51 | false 52 | DELETE 53 | DELETE 54 | JENKINS_ROOT 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /jenkins/plugins.txt: -------------------------------------------------------------------------------- 1 | credentials:1.24 2 | git:2.4.2 3 | git-client:1.19.4 4 | scm-api:0.2 5 | rebuild:1.25 6 | jobConfigHistory:2.12 7 | plugin-usage-plugin:0.3 8 | groovy:1.29 9 | job-dsl:1.42 10 | github-api:1.72 11 | github:1.17.0 12 | plain-credentials:1.1 13 | cloudbees-credentials:3.3 14 | config-file-provider:2.10.0 15 | token-macro:1.10 16 | parameterized-trigger:2.29 17 | clone-workspace-scm:0.6 18 | chucknorris:1.0 19 | xvfb:1.1.2 20 | ws-cleanup:0.28 21 | ansicolor:0.4.2 22 | junit:1.10 23 | xunit:1.100 24 | docker-build-publish:1.1 25 | docker-commons:1.3 26 | cloudbees-folder:5.1 27 | icon-shim:2.0.2 28 | authentication-tokens:1.1 29 | multiple-scms:0.5 30 | build-pipeline-plugin:1.5.1 31 | jquery:1.7.2-1 32 | dashboard-view:2.2 33 | -------------------------------------------------------------------------------- /jenkins/seedjobs/edmpSeedJob.groovy: -------------------------------------------------------------------------------- 1 | import groovy.json.JsonSlurper 2 | import hudson.FilePath 3 | import hudson.* 4 | 5 | println "############################################################################################################" 6 | println "Reading project configuration from json" 7 | 8 | hudson.FilePath workspace = hudson.model.Executor.currentExecutor().getCurrentWorkspace() 9 | File file = new File("${workspace}/jenkins/seedjobs/edmp-project-configuration.json") 10 | def slurper = new JsonSlurper() 11 | URL configFileUrl = new URL("${EDMP_CONFIG_URL}") 12 | projects = slurper.parseText(configFileUrl.text) 13 | 14 | println "############################################################################################################" 15 | println "Create Default Views and Admin Jobs" 16 | println "" 17 | 18 | def edmpGitUrl="https://github.com/codecentric/event-driven-microservices-platform" 19 | globalProdNetwork="eventdrivenmicroservicesplatform_prodnetwork" 20 | createDockerJob("docker-admin-version", "", "sudo /usr/bin/docker version", "") 21 | createDockerJob("docker-admin-list-running-container", "", "sudo /usr/bin/docker ps", "") 22 | createDockerJob("docker-admin-list-images", "", "sudo /usr/bin/docker images", "") 23 | createDockerJob("docker-admin-list-networks", "", "sudo /usr/bin/docker network ls", "") 24 | createDockerJob("edmp-sample-app-redis", "", "(sudo /usr/bin/docker stop edmp-sample-app-redis | true) && (sudo /usr/bin/docker rm edmp-sample-app-redis | true) && sudo /usr/bin/docker run -d --name edmp-sample-app-redis --net=${globalProdNetwork} redis", "") 25 | 26 | createListViews("Admin", "Contains all admin jobs", ".*admin-.*") 27 | createListViews("Docker Admin", "Contains all docker admin jobs", "docker-admin-.*") 28 | createListViews("EDMP Jobs", "Contains all Event Driven Microservices Platform jobs", "edmp-.*") 29 | 30 | println "############################################################################################################" 31 | println "Iterating all projects" 32 | println "" 33 | 34 | projects.each { 35 | println "############################################################################################################" 36 | println "" 37 | println "Creating Jenkins Jobs for Git Project: ${it.gitProjectName}" 38 | println "" 39 | println "- gitRepositoryUrl = ${it.gitRepositoryUrl}" 40 | println "- rootWorkDirectory = ${it.rootWorkDirectory}" 41 | println "- dockerPort = ${it.dockerPort}" 42 | println "" 43 | 44 | def jobNamePrefix = "${it.gitProjectName}" 45 | if( it.rootWorkDirectory != null ) { 46 | jobNamePrefix = "${it.gitProjectName}-${it.rootWorkDirectory}" 47 | } 48 | 49 | createCIJob(jobNamePrefix, it.gitProjectName, it.gitRepositoryUrl, it.rootWorkDirectory) 50 | createSonarJob(jobNamePrefix, it.gitProjectName, it.gitRepositoryUrl, it.rootWorkDirectory) 51 | createDockerBuildJob(jobNamePrefix, it.gitProjectName, it.dockerPort) 52 | def jobNameStop = jobNamePrefix + "-4-stop" 53 | createDockerJob(jobNameStop, "", "sudo /usr/bin/docker stop \$(sudo /usr/bin/docker ps -a -q --filter='name=${it.gitProjectName}') | true", "") 54 | 55 | } 56 | 57 | def createBuildPipelineView(def viewName, def viewTitle, def startJob) { 58 | println "############################################################################################################" 59 | println "Create buildPipelineView:" 60 | println "- viewName = ${viewName}" 61 | println "- viewTitle = ${viewTitle}" 62 | println "- startJob = ${startJob}" 63 | println "############################################################################################################" 64 | 65 | buildPipelineView(viewName) { 66 | filterBuildQueue() 67 | filterExecutors() 68 | title("${viewTitle}") 69 | displayedBuilds(5) 70 | selectedJob(startJob) 71 | alwaysAllowManualTrigger() 72 | showPipelineParameters() 73 | refreshFrequency(60) 74 | } 75 | } 76 | 77 | def createListViews(def title, def jobDescription, def reqularExpression) { 78 | 79 | println "############################################################################################################" 80 | println "Create ListView:" 81 | println "- title = ${title}" 82 | println "- description = ${jobDescription}" 83 | println "- reqularExpression = ${reqularExpression}" 84 | println "############################################################################################################" 85 | 86 | listView(title) { 87 | description(jobDescription) 88 | filterBuildQueue() 89 | filterExecutors() 90 | jobs { 91 | regex(reqularExpression) 92 | } 93 | columns { 94 | buildButton() 95 | weather() 96 | status() 97 | name() 98 | lastSuccess() 99 | lastFailure() 100 | lastDuration() 101 | } 102 | } 103 | } 104 | 105 | def createCIJob(def jobNamePrefix, def gitProjectName, def gitRepositoryUrl, def rootWorkDirectory) { 106 | 107 | println "############################################################################################################" 108 | println "Creating CI Job:" 109 | println "- jobNamePrefix = ${jobNamePrefix}" 110 | println "- gitProjectName = ${gitProjectName}" 111 | println "- gitRepositoryUrl = ${gitRepositoryUrl}" 112 | println "- rootWorkDirectory = ${rootWorkDirectory}" 113 | println "############################################################################################################" 114 | 115 | job("${jobNamePrefix}-1-ci") { 116 | logRotator { 117 | numToKeep(10) 118 | } 119 | parameters { 120 | stringParam("BRANCH", "master", "Define TAG or BRANCH to build from") 121 | stringParam("REPOSITORY_URL", "http://nexus:8081/nexus/content/repositories/releases/", "Nexus Release Repository URL") 122 | } 123 | scm { 124 | git { 125 | remote { 126 | url(gitRepositoryUrl) 127 | } 128 | createTag(false) 129 | clean() 130 | } 131 | } 132 | wrappers { 133 | colorizeOutput() 134 | preBuildCleanup() 135 | } 136 | triggers { 137 | scm('* * * * *') 138 | githubPush() 139 | } 140 | steps { 141 | maven { 142 | goals('clean versions:set -DnewVersion=\${BUILD_NUMBER} -U') 143 | mavenInstallation('Maven 3.3.3') 144 | if( rootWorkDirectory != null ) { 145 | rootPOM("${rootWorkDirectory}/pom.xml") 146 | } else { 147 | rootPOM("pom.xml") 148 | } 149 | mavenOpts('-Xms512m -Xmx1024m') 150 | providedGlobalSettings('MyGlobalSettings') 151 | } 152 | maven { 153 | goals('clean deploy -U -DaltDeploymentRepository=nexus-release-repository::default::$REPOSITORY_URL') 154 | mavenInstallation('Maven 3.3.3') 155 | if( rootWorkDirectory != null ) { 156 | rootPOM("${rootWorkDirectory}/pom.xml") 157 | } else { 158 | rootPOM("pom.xml") 159 | } 160 | mavenOpts('-Xms512m -Xmx1024m') 161 | providedGlobalSettings('MyGlobalSettings') 162 | } 163 | } 164 | publishers { 165 | chucknorris() 166 | archiveXUnit { 167 | jUnit { 168 | pattern('**/surefire-reports/*.xml') 169 | skipNoTestFiles(true) 170 | stopProcessingIfError(false) 171 | } 172 | } 173 | publishCloneWorkspace('**', '', 'Any', 'TAR', true, null) 174 | downstreamParameterized { 175 | trigger("${jobNamePrefix}-2-sonar") { 176 | currentBuild() 177 | } 178 | } 179 | } 180 | } 181 | } 182 | 183 | def createSonarJob(def jobNamePrefix, def gitProjectName, def gitRepositoryUrl, def rootWorkDirectory) { 184 | 185 | println "############################################################################################################" 186 | println "Creating Sonar Job:" 187 | println "- jobNamePrefix = ${jobNamePrefix}" 188 | println "- gitProjectName = ${gitProjectName}" 189 | println "- gitRepositoryUrl = ${gitRepositoryUrl}" 190 | println "- rootWorkDirectory = ${rootWorkDirectory}" 191 | println "############################################################################################################" 192 | 193 | job("${jobNamePrefix}-2-sonar") { 194 | logRotator { 195 | numToKeep(10) 196 | } 197 | parameters { 198 | stringParam("BRANCH", "master", "Define TAG or BRANCH to build from") 199 | } 200 | scm { 201 | cloneWorkspace("${jobNamePrefix}-1-ci") 202 | } 203 | wrappers { 204 | colorizeOutput() 205 | preBuildCleanup() 206 | } 207 | steps { 208 | maven { 209 | goals('org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent install -Psonar -U') 210 | mavenInstallation('Maven 3.3.3') 211 | if( rootWorkDirectory != null ) { 212 | rootPOM("${rootWorkDirectory}/pom.xml") 213 | } else { 214 | rootPOM("pom.xml") 215 | } 216 | mavenOpts('-Xms512m -Xmx1024m') 217 | providedGlobalSettings('MyGlobalSettings') 218 | } 219 | maven { 220 | goals('sonar:sonar -Psonar -U') 221 | mavenInstallation('Maven 3.3.3') 222 | if( rootWorkDirectory != null ) { 223 | rootPOM("${rootWorkDirectory}/pom.xml") 224 | } else { 225 | rootPOM("pom.xml") 226 | } 227 | mavenOpts('-Xms512m -Xmx1024m') 228 | providedGlobalSettings('MyGlobalSettings') 229 | } 230 | } 231 | publishers { 232 | chucknorris() 233 | downstreamParameterized { 234 | trigger("${jobNamePrefix}-3-docker-build") { 235 | currentBuild() 236 | } 237 | } 238 | } 239 | } 240 | } 241 | 242 | def createDockerBuildJob(def jobNamePrefix, def gitProjectName, def dockerPort) { 243 | println "############################################################################################################" 244 | println "Creating Docker Build Job ${jobNamePrefix} for gitProjectName=${gitProjectName}" 245 | println "############################################################################################################" 246 | 247 | job("${jobNamePrefix}-3-docker-build") { 248 | logRotator { 249 | numToKeep(10) 250 | } 251 | scm { 252 | cloneWorkspace("${jobNamePrefix}-1-ci") 253 | } 254 | steps { 255 | steps { 256 | shell("sudo /usr/bin/docker build -t ${gitProjectName} .") 257 | shell("sudo /usr/bin/docker stop \$(sudo /usr/bin/docker ps -a -q --filter='name=${gitProjectName}') | true") 258 | shell("sudo /usr/bin/docker rm \$(sudo /usr/bin/docker ps -a -q --filter='name=${gitProjectName}') | true") 259 | shell("sudo /usr/bin/docker run -d --name ${gitProjectName} --net=${globalProdNetwork} -p=${dockerPort} ${gitProjectName}") 260 | } 261 | } 262 | publishers { 263 | chucknorris() 264 | } 265 | } 266 | } 267 | 268 | def createDockerJob(def jobName, def workspaceDir, def shellCommand, def gitRepository) { 269 | 270 | println "############################################################################################################" 271 | println "Creating Docker Job ${jobName} for gitRepository=${gitRepository} and workspaceDir=${workspaceDir}" 272 | println "############################################################################################################" 273 | 274 | job(jobName) { 275 | logRotator { 276 | numToKeep(10) 277 | } 278 | scm { 279 | if( "${workspaceDir}".size() > 0 ) { 280 | cloneWorkspace("${workspaceDir}") 281 | } else { 282 | if( "${gitRepository}".size() > 0 ) { 283 | git { 284 | remote { 285 | url(gitRepository) 286 | } 287 | createTag(false) 288 | clean() 289 | } 290 | } 291 | } 292 | } 293 | steps { 294 | steps { 295 | shell(shellCommand) 296 | } 297 | } 298 | publishers { 299 | chucknorris() 300 | } 301 | } 302 | } 303 | -------------------------------------------------------------------------------- /nexus/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Creates a docker container with Nexus Artifact Repository 3 | # 4 | 5 | FROM centos:6 6 | 7 | MAINTAINER Marcel Birkner 8 | 9 | USER root 10 | # Update the system 11 | RUN yum -y update; \ 12 | yum clean all 13 | 14 | ########################################################## 15 | # Install Java JDK, SSH and other useful cmdline utilities 16 | ########################################################## 17 | RUN yum -y install java-1.7.0-openjdk-devel \ 18 | which \ 19 | telnet \ 20 | unzip \ 21 | openssh-server \ 22 | sudo \ 23 | openssh-clients \ 24 | iputils \ 25 | iproute \ 26 | httpd-tools \ 27 | wget \ 28 | tar; \ 29 | yum clean all 30 | ENV JAVA_HOME /usr/lib/jvm/jre 31 | 32 | ENV NEXUS_VERSION 2.12.0-01 33 | 34 | ########################################################## 35 | # Install Nexus 36 | ########################################################## 37 | RUN mkdir -p /opt/sonatype-nexus /opt/sonatype-work 38 | RUN wget -O /tmp/nexus-latest-bundle.tar.gz http://download.sonatype.com/nexus/oss/nexus-$NEXUS_VERSION-bundle.tar.gz 39 | RUN tar xzvf /tmp/nexus-latest-bundle.tar.gz -C /opt/sonatype-nexus --strip-components=1 40 | RUN useradd --user-group --system --home-dir /opt/sonatype-nexus nexus 41 | 42 | ADD nexus.xml /opt/sonatype-work/nexus/conf/nexus.xml 43 | 44 | RUN chown -R nexus:nexus /opt/sonatype-work /opt/sonatype-nexus 45 | 46 | ENV NEXUS_WEBAPP_CONTEXT_PATH /nexus 47 | RUN echo "#!/bin/bash" > /opt/start-nexus.sh 48 | RUN echo "su -c \"/opt/sonatype-nexus/bin/nexus console\" - nexus" >> /opt/start-nexus.sh 49 | RUN chmod +x /opt/start-nexus.sh 50 | 51 | CMD ["/opt/start-nexus.sh"] 52 | EXPOSE 8081 53 | -------------------------------------------------------------------------------- /nexus/README.md: -------------------------------------------------------------------------------- 1 | ## Nexus Docker Container 2 | 3 | The Dockerfile builds and starts a Nexus repository and configures the JBoss Enterprise maven repos on Nexus. 4 | 5 | Usage: 6 | ``` 7 | $ docker build -t nexus . 8 | $ docker run -d -p 8081:8081 nexus 9 | ``` 10 | -------------------------------------------------------------------------------- /nexus/nexus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.8.0 4 | 2.8.1-01 5 | 6 | 20000 7 | 3 8 | 9 | 10 | 11 | 60000 12 | 13 | 14 | true 15 | 8082 16 | strict 17 | 18 | 19 | true 20 | 21 | 22 | 23 | central 24 | Central 25 | org.sonatype.nexus.proxy.repository.Repository 26 | maven2 27 | IN_SERVICE 28 | true 29 | 1440 30 | true 31 | true 32 | true 33 | READ_ONLY 34 | true 35 | true 36 | 37 | file 38 | 39 | 40 | http://repo1.maven.org/maven2/ 41 | 42 | 43 | ALLOW 44 | -1 45 | 1440 46 | false 47 | false 48 | WARN 49 | RELEASE 50 | 51 | 52 | 53 | apache-snapshots 54 | Apache Snapshots 55 | org.sonatype.nexus.proxy.repository.Repository 56 | maven2 57 | IN_SERVICE 58 | true 59 | 1440 60 | true 61 | true 62 | true 63 | READ_ONLY 64 | true 65 | true 66 | 67 | file 68 | 69 | 70 | http://repository.apache.org/snapshots/ 71 | 72 | 73 | ALLOW 74 | 1440 75 | 1440 76 | false 77 | false 78 | WARN 79 | SNAPSHOT 80 | 81 | 82 | 83 | codehaus-snapshots 84 | Codehaus Snapshots 85 | org.sonatype.nexus.proxy.repository.Repository 86 | maven2 87 | IN_SERVICE 88 | true 89 | 1440 90 | true 91 | true 92 | true 93 | READ_ONLY 94 | true 95 | true 96 | 97 | file 98 | 99 | 100 | http://nexus.codehaus.org/snapshots/ 101 | 102 | 103 | ALLOW 104 | 1440 105 | 1440 106 | false 107 | false 108 | WARN 109 | SNAPSHOT 110 | 111 | 112 | 113 | releases 114 | Releases 115 | org.sonatype.nexus.proxy.repository.Repository 116 | maven2 117 | IN_SERVICE 118 | 1440 119 | true 120 | true 121 | true 122 | ALLOW_WRITE_ONCE 123 | true 124 | true 125 | 126 | file 127 | 128 | 129 | ALLOW 130 | -1 131 | 1440 132 | false 133 | false 134 | WARN 135 | RELEASE 136 | 137 | 138 | 139 | snapshots 140 | Snapshots 141 | org.sonatype.nexus.proxy.repository.Repository 142 | maven2 143 | IN_SERVICE 144 | 1440 145 | true 146 | true 147 | true 148 | ALLOW_WRITE 149 | true 150 | true 151 | 152 | file 153 | 154 | 155 | ALLOW 156 | 1440 157 | 1440 158 | false 159 | false 160 | WARN 161 | SNAPSHOT 162 | 163 | 164 | 165 | thirdparty 166 | 3rd party 167 | org.sonatype.nexus.proxy.repository.Repository 168 | maven2 169 | IN_SERVICE 170 | 1440 171 | true 172 | true 173 | true 174 | ALLOW_WRITE_ONCE 175 | true 176 | true 177 | 178 | file 179 | 180 | 181 | ALLOW 182 | -1 183 | 1440 184 | false 185 | false 186 | WARN 187 | RELEASE 188 | 189 | 190 | 191 | central-m1 192 | Central M1 shadow 193 | org.sonatype.nexus.proxy.repository.ShadowRepository 194 | m2-m1-shadow 195 | IN_SERVICE 196 | 15 197 | true 198 | true 199 | true 200 | READ_ONLY 201 | 202 | file 203 | 204 | 205 | central 206 | false 207 | 208 | 209 | 210 | public 211 | Public Repositories 212 | org.sonatype.nexus.proxy.repository.GroupRepository 213 | maven2 214 | IN_SERVICE 215 | 15 216 | true 217 | true 218 | true 219 | READ_ONLY 220 | true 221 | 222 | file 223 | 224 | 225 | true 226 | 227 | releases 228 | snapshots 229 | thirdparty 230 | central 231 | jboss-ea-repository 232 | jboss-ga-repository 233 | spring-snapshots 234 | spring-milestones 235 | spring-boot-admin-snapshots 236 | 237 | 238 | 239 | 240 | jboss-ga-repository 241 | JBoss Enterprise GA Repository 242 | org.sonatype.nexus.proxy.repository.Repository 243 | maven2 244 | IN_SERVICE 245 | true 246 | 1440 247 | true 248 | true 249 | true 250 | READ_ONLY 251 | true 252 | true 253 | 254 | file 255 | 256 | 257 | http://maven.repository.redhat.com/techpreview/all/ 258 | 259 | 260 | RELEASE 261 | WARN 262 | true 263 | true 264 | -1 265 | 1440 266 | 1440 267 | true 268 | 269 | 270 | 271 | jboss-ea-repository 272 | JBoss Enterprise EA Repository 273 | org.sonatype.nexus.proxy.repository.Repository 274 | maven2 275 | IN_SERVICE 276 | true 277 | 1440 278 | true 279 | true 280 | true 281 | READ_ONLY 282 | true 283 | true 284 | 285 | file 286 | 287 | 288 | http://maven.repository.redhat.com/earlyaccess/all/ 289 | 290 | 291 | RELEASE 292 | WARN 293 | true 294 | true 295 | -1 296 | 1440 297 | 1440 298 | true 299 | 300 | 301 | 302 | 303 | spring-snapshots 304 | spring-snapshots 305 | org.sonatype.nexus.proxy.repository.Repository 306 | maven2 307 | IN_SERVICE 308 | true 309 | 1440 310 | true 311 | true 312 | true 313 | READ_ONLY 314 | true 315 | true 316 | 317 | file 318 | 319 | 320 | https://repo.spring.io/snapshot/ 321 | 322 | 323 | SNAPSHOT 324 | WARN 325 | true 326 | true 327 | -1 328 | 1440 329 | 1440 330 | true 331 | 332 | 333 | 334 | spring-milestones 335 | spring-milestones 336 | org.sonatype.nexus.proxy.repository.Repository 337 | maven2 338 | IN_SERVICE 339 | true 340 | 1440 341 | true 342 | true 343 | true 344 | READ_ONLY 345 | true 346 | true 347 | 348 | file 349 | 350 | 351 | https://repo.spring.io/milestone/ 352 | 353 | 354 | RELEASE 355 | WARN 356 | true 357 | true 358 | -1 359 | 1440 360 | 1440 361 | true 362 | 363 | 364 | 365 | spring-boot-admin-snapshots 366 | spring-boot-admin-snapshots 367 | org.sonatype.nexus.proxy.repository.Repository 368 | maven2 369 | IN_SERVICE 370 | true 371 | 1440 372 | true 373 | true 374 | true 375 | READ_ONLY 376 | true 377 | true 378 | 379 | file 380 | 381 | 382 | https://oss.sonatype.org/content/repositories/snapshots/ 383 | 384 | 385 | SNAPSHOT 386 | WARN 387 | true 388 | true 389 | -1 390 | 1440 391 | 1440 392 | true 393 | 394 | 395 | 396 | 397 | 398 | 399 | inhouse-stuff 400 | * 401 | inclusive 402 | 403 | ^/(com|org)/somecompany/.* 404 | 405 | 406 | snapshots 407 | releases 408 | 409 | 410 | 411 | apache-stuff 412 | * 413 | exclusive 414 | 415 | ^/org/some-oss/.* 416 | 417 | 418 | releases 419 | snapshots 420 | 421 | 422 | 423 | 424 | 425 | 426 | 1 427 | All (Maven2) 428 | maven2 429 | 430 | .* 431 | 432 | 433 | 434 | 2 435 | All (Maven1) 436 | maven1 437 | 438 | .* 439 | 440 | 441 | 442 | 3 443 | All but sources (Maven2) 444 | maven2 445 | 446 | (?!.*-sources.*).* 447 | 448 | 449 | 450 | 4 451 | All Metadata (Maven2) 452 | maven2 453 | 454 | .*maven-metadata\.xml.* 455 | 456 | 457 | 458 | any 459 | All (Any Repository) 460 | any 461 | 462 | .* 463 | 464 | 465 | 466 | site 467 | All (site) 468 | site 469 | 470 | .* 471 | 472 | 473 | 474 | 475 | smtp-host 476 | 25 477 | smtp-username 478 | {MmqzUrAMLBUH7UbclOKupoeDlMvIWHQEnzDwIckrX38=} 479 | system@nexus.org 480 | 481 | 482 | 483 | -------------------------------------------------------------------------------- /sonar/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Creates a docker container with SonarQube, incl. several plugins 3 | # Since the original Dockerfile does not support plugins, I 4 | # had to extend the Dockerfile 5 | # 6 | # Original: https://hub.docker.com/_/sonarqube/ 7 | # 8 | 9 | FROM java:openjdk-8u45-jdk 10 | 11 | MAINTAINER Marcel Birkner 12 | 13 | ENV SONARQUBE_HOME /opt/sonarqube 14 | 15 | # Http port 16 | EXPOSE 9000 17 | 18 | # H2 Database port 19 | EXPOSE 9092 20 | 21 | # Database configuration 22 | # Defaults to using H2 23 | ENV SONARQUBE_JDBC_USERNAME sonar 24 | ENV SONARQUBE_JDBC_PASSWORD sonar 25 | ENV SONARQUBE_JDBC_URL jdbc:h2:tcp://localhost:9092/sonar 26 | 27 | ENV SONAR_DOWNLOAD_URL https://sonarsource.bintray.com/Distribution 28 | 29 | ENV SONAR_VERSION 5.3 30 | 31 | # pub 2048R/D26468DE 2015-05-25 32 | # Key fingerprint = F118 2E81 C792 9289 21DB CAB4 CFCA 4A29 D264 68DE 33 | # uid sonarsource_deployer (Sonarsource Deployer) 34 | # sub 2048R/06855C1D 2015-05-25 35 | RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE 36 | 37 | RUN set -x \ 38 | && cd /opt \ 39 | && curl -o sonarqube.zip -fSL https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip \ 40 | && curl -o sonarqube.zip.asc -fSL https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc \ 41 | && gpg --verify sonarqube.zip.asc \ 42 | && unzip sonarqube.zip \ 43 | && mv sonarqube-$SONAR_VERSION sonarqube \ 44 | && rm sonarqube.zip* \ 45 | && rm -rf $SONARQUBE_HOME/bin/* 46 | 47 | # Installing Plugins 48 | RUN cd /opt/sonarqube/extensions/plugins/ \ 49 | && curl -o sonar-java-plugin-3.9.jar -fSL $SONAR_DOWNLOAD_URL/sonar-java-plugin/sonar-java-plugin-3.9.jar \ 50 | && curl -o sonar-web-plugin-2.4.jar -fSL $SONAR_DOWNLOAD_URL/sonar-web-plugin/sonar-web-plugin-2.4.jar \ 51 | && curl -o sonar-scm-git-plugin-1.1.jar -fSL http://downloads.sonarsource.com/plugins/org/codehaus/sonar-plugins/sonar-scm-git-plugin/1.1/sonar-scm-git-plugin-1.1.jar 52 | 53 | VOLUME ["$SONARQUBE_HOME/data", "$SONARQUBE_HOME/extensions"] 54 | 55 | WORKDIR $SONARQUBE_HOME 56 | COPY run.sh $SONARQUBE_HOME/bin/ 57 | RUN chmod +x $SONARQUBE_HOME/bin/run.sh 58 | 59 | ENTRYPOINT ["./bin/run.sh"] 60 | -------------------------------------------------------------------------------- /sonar/README.md: -------------------------------------------------------------------------------- 1 | ## SonarQube Docker Container 2 | 3 | Usage: 4 | ``` 5 | $ docker build -t sonar . 6 | $ docker run -d -p 8800:9000 sonar 7 | ``` 8 | -------------------------------------------------------------------------------- /sonar/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "${1:0:1}" != '-' ]; then 5 | exec "$@" 6 | fi 7 | 8 | exec java -jar lib/sonar-application-$SONAR_VERSION.jar \ 9 | -Dsonar.log.console=true \ 10 | -Dsonar.jdbc.username="$SONARQUBE_JDBC_USERNAME" \ 11 | -Dsonar.jdbc.password="$SONARQUBE_JDBC_PASSWORD" \ 12 | -Dsonar.jdbc.url="$SONARQUBE_JDBC_URL" \ 13 | -Dsonar.web.javaAdditionalOpts="-Djava.security.egd=file:/dev/./urandom" \ 14 | "$@" 15 | --------------------------------------------------------------------------------