├── .gitattribute ├── .gitignore ├── LICENSE ├── README.md ├── jenkins-base ├── Dockerfile └── provision │ ├── bootstrap.sh │ ├── bootstrap_aws.sh │ ├── bootstrap_python.sh │ ├── jenkins_install_plugins.sh │ ├── jenkins_plugins.txt │ └── jenkins_plugins_python.txt ├── jenkins-server ├── Dockerfile ├── Vagrantfile ├── aws-config-example.yml ├── data │ └── jenkins │ │ ├── build_python.sh │ │ ├── config.xml │ │ └── jobs │ │ ├── PipelineDemo │ │ └── config.xml │ │ └── Python_Pipeline │ │ ├── config.xml │ │ └── requirements.txt └── provision │ ├── bootstrap.sh │ ├── bootstrap_aws.sh │ ├── bootstrap_copy_project.sh │ ├── bootstrap_python.sh │ ├── jenkins_install_plugins.sh │ ├── jenkins_plugins.txt │ └── jenkins_plugins_python.txt └── preview.jpg /.gitattribute: -------------------------------------------------------------------------------- 1 | # Declare files that will always have CRLF line endings on checkout. 2 | *.sh text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .project 3 | .pydevproject 4 | 5 | .vagrant/** 6 | .vagrant/ 7 | **/.vagrant/** 8 | **/.vagrant/ 9 | 10 | aws-config.yml 11 | **/aws-config.yml 12 | 13 | data/gruyere.tar 14 | data/painite.tar 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Apollo Clark 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 | # Jenkins - Pipeline 2 | 3 | Demo of the Jenkins Pipeline plugin, using Vagrant to run an Ubuntu 14.04 LTS 4 | 64-bit instance, locally using Virtualbox, or remotely using Amazon. It will 5 | pull down and use whatever the latest Jenkins Stable build is. 6 | 7 | ![alt text](https://github.com/apolloclark/vagrant-jenkins-pipeline/blob/master/preview.jpg "Jenkins Pipeline preview") 8 | 9 | 10 | 11 | ## Docker-compose, run Server and Clients 12 | ```shell 13 | # run Server and Client Docker images 14 | docker-compose up 15 | # open a browser: http://127.0.0.1:8080/ 16 | 17 | # job/PipelineDemo/ 18 | # click "Build Now" 19 | 20 | # shutdown 21 | docker-compose stop 22 | 23 | # cleanup 24 | docker-compose rm -f 25 | ``` 26 | 27 | 28 | 29 | 30 | ## Docker, run Server 31 | ```shell 32 | # change dir 33 | cd jenkins-server 34 | 35 | # build 36 | docker build --no-cache=true -t apolloclark/jenkins-server . 37 | 38 | # run 39 | docker run -it -p 8080:8080 -p 50000:50000 apolloclark/jenkins-server 40 | 41 | # open a browser: http://127.0.0.1:8080/job/PipelineDemo/ 42 | # click "Build Now" 43 | ``` 44 | 45 | 46 | 47 | 48 | 49 | ## Vagrant 50 | ```shell 51 | # change dir 52 | cd jenkins-server 53 | 54 | # install the vagrant aws provider 55 | vagrant plugin install vagrant-aws 56 | 57 | # copy the example AWS config 58 | cp -f aws-config-example.yml aws-config.yml 59 | 60 | # run 61 | vagrant up 62 | # open a browser: http://127.0.0.1:8080/job/PipelineDemo/ 63 | # click "Build Now" 64 | ``` 65 | 66 | 67 | 68 | 69 | 70 | ## Deploy to Amazon 71 | ```shell 72 | 73 | # install the vagrant aws provider 74 | vagrant plugin install vagrant-aws 75 | 76 | # clone the repo 77 | git clone https://github.com/apolloclark/vagrant-jenkins-pipeline 78 | cd vagrant-jenkins-pipeline 79 | 80 | # copy the example AWS config, customize 81 | cp -f aws-config-example.yml aws-config.yml 82 | 83 | 84 | # run 85 | vagrant up --provider=aws 86 | # open a browser: http://:8080/job/Python_Pipeline/ 87 | # click "Build Now" 88 | 89 | 90 | # create SSH port forwarding tunnel 91 | ssh -L 8080:127.0.0.1:8080 admin@ -i 92 | 93 | # create SSH port forwarding tunnel without a Terminal 94 | ssh -nNT -L 8080:127.0.0.1:8080 admin@ -i 95 | ``` 96 | 97 | 98 | 99 | 100 | 101 | ## Jenkins Logs 102 | ```shell 103 | watch tail -n 32 /var/log/jenkins/jenkins.log 104 | ``` 105 | 106 | 107 | 108 | ## Painite attacks 109 | ```shell 110 | # scan the local network 111 | nmap -sn -vv 172.17.0.1/24 112 | 113 | # TCP SYN port scan a specific IP 114 | nmap -sS -vv 172.17.0.2 115 | 116 | # attempt to connect 117 | curl -i http://172.17.0.2:8008/1677330664470980985/ | less 118 | 119 | # list all the DIRB wordlists 120 | ls -lah /usr/share/dirb/wordlists/ 121 | ls -lah /usr/share/dirb/wordlists/others 122 | ls -lah /usr/share/dirb/wordlists/vulns 123 | 124 | # run the dirb attack, filter out responses that are 250 bytes 125 | dirb http://172.17.0.2:8008/1677330664470980985/ \ 126 | /usr/share/dirb/wordlists/common.txt -f \ 127 | | grep -v 250 128 | 129 | 130 | ``` 131 | 132 | 133 | 134 | 135 | ## Configure for Programming Language 136 | 137 | There are multiple sub-projects within the ./data folder, which are Quickstarts 138 | for various programming languages and web frameworks. You can edit the 139 | Vagrantfile to install language specific code quality tools, and enable 140 | language specific Build projects. 141 | 142 | ## Links 143 | 144 | - https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin 145 | - https://dzone.com/refcardz/continuous-delivery-with-jenkins-workflow 146 | - https://documentation.cloudbees.com/docs/cookbook/pipeline-as-code.html 147 | - http://udaypal.com/jenkins-workflow-getting-started/ 148 | - https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins 149 |
150 | 151 | - https://github.com/jenkinsci/pipeline-examples/tree/master/pipeline-examples 152 | - https://github.com/jenkinsci/workflow-aggregator-plugin/blob/master/demo/plugins.txt 153 | - https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md 154 |
155 | 156 | - https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial 157 |
158 | 159 | - http://www.slideshare.net/cloudbees/pimp-your-continuous-delivery-pipeline-with-jenkins-workflow-wjax-14/20 160 | 161 | -------------------------------------------------------------------------------- /jenkins-base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Apollo Clark apolloclark@gmail.com 3 | 4 | # Describe the environment 5 | ENV DEBIAN_FRONTEND "noninteractive" 6 | ENV JDK_VERSION 1.8.0_111 7 | ENV JENKINS_VERSION 2.32.1 8 | 9 | # install Jenkins 10 | COPY ./provision /vagrant 11 | RUN chmod +x /vagrant/bootstrap.sh; \ 12 | sync; \ 13 | /vagrant/bootstrap.sh 14 | 15 | RUN chmod +x /vagrant/bootstrap_python.sh; \ 16 | sync; \ 17 | /vagrant/bootstrap_python.sh 18 | 19 | EXPOSE 8080 20 | -------------------------------------------------------------------------------- /jenkins-base/provision/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # update system 7 | apt-get update 8 | apt-get upgrade -y 9 | apt-get install -y wget curl unzip unzip wget daemon python-setuptools \ 10 | software-properties-common git-core ca-certificates 11 | 12 | 13 | 14 | 15 | 16 | # Install OpenJDK 8 17 | 18 | # Sets language to UTF8 : this works in pretty much all cases 19 | locale-gen en_US.UTF-8 20 | 21 | # add repo, update, install 22 | add-apt-repository -y ppa:openjdk-r/ppa 2>&1 23 | apt-get update 24 | apt-get install -y openjdk-8-jre-headless 25 | export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/" 26 | 27 | 28 | 29 | 30 | 31 | # Install Jenkins 32 | # @see https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu 33 | wget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | \ 34 | apt-key add - 35 | echo "deb http://pkg.jenkins-ci.org/debian-stable binary/" | \ 36 | sudo tee /etc/apt/sources.list.d/jenkins.list 37 | add-apt-repository -y ppa:openjdk-r/ppa 2>&1 38 | apt-get update 39 | apt-get install -y jenkins 40 | 41 | # hackish way to install a specific version of Jenkins 42 | # dpkg --install /vagrant/jenkins_1.642_all.deb 43 | # service jenkins restart 44 | 45 | 46 | 47 | # Install Jenkins plugins 48 | # @see http://updates.jenkins-ci.org/download/plugins/ 49 | # @see /var/lib/jenkins/plugins/ 50 | # @see https://github.com/jenkinsci/workflow-aggregator-plugin/blob/master/demo/plugins.txt 51 | 52 | # install the Jenkins plugins 53 | echo "INFO: Installing Jenkins plugins..." 54 | mkdir -p /var/lib/jenkins/plugins/ 55 | chmod -R 0777 /var/lib/jenkins/plugins 56 | /vagrant/jenkins_install_plugins.sh /vagrant/jenkins_plugins.txt 57 | # service jenkins restart 58 | 59 | # clear the logs, set folder permissions, restart 60 | chmod -R 0777 /var/lib/jenkins/plugins 61 | rm -f /var/log/jenkins/jenkins.log 62 | # service jenkins restart 63 | echo "INFO: Done installing Jenkins plugins." 64 | -------------------------------------------------------------------------------- /jenkins-base/provision/bootstrap_aws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # Autoresize the EC2 root EBS partition, if needed 7 | if [[ $(df -h | grep 'xvda1') ]]; then 8 | /sbin/parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100% 9 | resize2fs /dev/xvda1 10 | fi 11 | -------------------------------------------------------------------------------- /jenkins-base/provision/bootstrap_python.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # Install various dependencies 7 | apt-get -y install build-essential libreadline-gplv2-dev libncursesw5-dev \ 8 | libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev sshpass \ 9 | sloccount sqlite3 libsqlite3-dev 10 | 11 | 12 | 13 | # Install Python 14 | echo "INFO: Installing Python..." 15 | apt-get -y install python2.7 python-pip python-dev libpq-dev libffi-dev \ 16 | libssl-dev 17 | pip install --upgrade pip > /dev/null 2>&1 18 | # @see https://pip.pypa.io/en/latest/reference/pip.html 19 | 20 | # Install code quality tools 21 | pip install -qqq pylint > /dev/null 22 | pip install --quiet mock coverage nose nosexcover clonedigger ndg-httpsclient \ 23 | pyasn1 > /dev/null 2>&1 24 | 25 | # Install Flask requirements 26 | pip install -qqq -r /vagrant/jobs/Python_Pipeline/requirements.txt > /dev/null 2>&1 27 | echo "INFO: Done installing Python." 28 | 29 | # create folder for SQLite DB 30 | mkdir -p /tmp/tmp 31 | touch /tmp/tmp/sample.db 32 | chown www-data:www-data /tmp/tmp/sample.db 33 | chown www-data:www-data /tmp/tmp 34 | chmod -R 777 /tmp/tmp 35 | 36 | 37 | 38 | 39 | 40 | # Install Jenkins Python plugins 41 | # @see http://updates.jenkins-ci.org/download/plugins/ 42 | # @see /var/lib/jenkins/plugins/ 43 | echo "INFO: Installing Jenkins plugins..." 44 | mkdir -p /var/lib/jenkins/plugins/ 45 | chown -R jenkins:jenkins /var/lib/jenkins/plugins 46 | /vagrant/jenkins_install_plugins.sh /vagrant/jenkins_plugins_python.txt 47 | chown -R jenkins:jenkins /var/lib/jenkins/plugins 48 | 49 | # clear the logs, set folder permissions, restart 50 | rm -f /var/log/jenkins/jenkins.log 51 | echo "INFO: Done installing Jenkins plugins." 52 | -------------------------------------------------------------------------------- /jenkins-base/provision/jenkins_install_plugins.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # @see https://github.com/jenkinsci/docker/blob/master/plugins.sh 4 | # Parse a support-core plugin -style txt file as specification for jenkins plugins to be installed 5 | # in the reference directory, so user can define a derived Docker image with just : 6 | # 7 | # FROM jenkins 8 | # COPY plugins.txt /plugins.txt 9 | # RUN /usr/local/bin/plugins.sh /plugins.txt 10 | # 11 | 12 | set -e 13 | 14 | REF=/var/lib/jenkins/plugins 15 | JENKINS_UC_DOWNLOAD="http://updates.jenkins-ci.org/download" 16 | mkdir -p $REF 17 | 18 | while read spec || [ -n "$spec" ]; do 19 | plugin=(${spec//:/ }); 20 | [[ ${plugin[0]} =~ ^# ]] && continue 21 | [[ ${plugin[0]} =~ ^\s*$ ]] && continue 22 | [[ -z ${plugin[1]} ]] && plugin[1]="latest" 23 | echo "${JENKINS_UC_DOWNLOAD}/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi" 24 | 25 | if [ -z "$JENKINS_UC_DOWNLOAD" ]; then 26 | JENKINS_UC_DOWNLOAD=$JENKINS_UC/download 27 | fi 28 | 29 | curl -sSL -f ${JENKINS_UC_DOWNLOAD}/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi -o $REF/${plugin[0]}.hpi 30 | done < $1 -------------------------------------------------------------------------------- /jenkins-base/provision/jenkins_plugins.txt: -------------------------------------------------------------------------------- 1 | ace-editor:1.1 2 | branch-api:1.11.1 3 | cloudbees-folder:5.15 4 | credentials:2.1.10 5 | display-url-api:0.5 6 | durable-task:1.12 7 | git-client:2.1.0 8 | git:3.0.1 9 | git-server:1.7 10 | github-api:1.82 11 | handlebars:1.1.1 12 | icon-shim:2.0.3 13 | jquery-detached:1.2.1 14 | junit:1.19 15 | mailer:1.18 16 | matrix-project:1.7.1 17 | mock-slave:1.10 18 | momentjs:1.1.1 19 | pipeline-build-step:2.4 20 | pipeline-graph-analysis:1.3 21 | pipeline-input-step:2.5 22 | pipeline-milestone-step:1.2 23 | pipeline-rest-api:2.4 24 | pipeline-stage-step:2.2 25 | pipeline-stage-view:2.4 26 | scm-api:1.3 27 | script-security:1.24 28 | ssh-credentials:1.12 29 | structs:1.5 30 | workflow-aggregator:2.4 31 | workflow-api:2.8 32 | workflow-basic-steps:2.3 33 | workflow-cps:2.23 34 | workflow-cps-global-lib:2.5 35 | workflow-durable-task-step:2.5 36 | workflow-job:2.9 37 | workflow-multibranch:2.9.2 38 | workflow-scm-step:2.3 39 | workflow-step-api:2.6 40 | workflow-support:2.11 -------------------------------------------------------------------------------- /jenkins-base/provision/jenkins_plugins_python.txt: -------------------------------------------------------------------------------- 1 | cobertura:1.9.8 2 | javadoc:1.4 3 | maven-plugin:2.14 4 | performance:2.0 5 | sloccount:1.21 6 | token-macro:2.0 7 | violations:0.7.11 -------------------------------------------------------------------------------- /jenkins-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM apolloclark/jenkins-base 2 | MAINTAINER Apollo Clark apolloclark@gmail.com 3 | 4 | # Describe the environment 5 | ENV DEBIAN_FRONTEND "noninteractive" 6 | 7 | # copy over the config and jobs 8 | COPY ./data/jenkins /root/jenkins 9 | RUN chmod +x /vagrant/bootstrap_copy_project.sh; \ 10 | sync; \ 11 | /vagrant/bootstrap_copy_project.sh 12 | 13 | EXPOSE 8080 14 | 15 | CMD service jenkins start && tail -F /var/log/jenkins/jenkins.log 16 | -------------------------------------------------------------------------------- /jenkins-server/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | 9 | # use the empty dummy box 10 | config.vm.box = "dummy" 11 | config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" 12 | 13 | # default provisioning script 14 | config.vm.provision :shell, path: "./provision/bootstrap.sh" 15 | 16 | # language specific Pipelines: 17 | # Python 18 | config.vm.provision :shell, path: "./provision/bootstrap_python.sh" 19 | # PHP 20 | # config.vm.provision :shell, path: "./provision/bootstrap_php.sh" 21 | # Java 22 | # config.vm.provision :shell, path: "./provision/bootstrap_java.sh" 23 | 24 | # copy over config and default job 25 | config.vm.provision :shell, path: "./provision/bootstrap_copy_project.sh" 26 | 27 | # run Jenkins 28 | config.vm.provision "shell", inline: "service jenkins restart" 29 | 30 | # Use Virtualbox by default 31 | config.vm.provider "virtualbox" 32 | config.vm.provider "aws" 33 | 34 | 35 | 36 | # Configure Virtulbox provider 37 | config.vm.provider "virtualbox" do |vb, override| 38 | 39 | override.vm.box = "ubuntu/trusty64" 40 | config.vm.box_url = "https://atlas.hashicorp.com/ubuntu/boxes/trusty64" 41 | 42 | vb.cpus = 1 43 | vb.memory = "1024" 44 | vb.gui = false 45 | 46 | override.vm.network "forwarded_port", guest: 8080, host: 8080 47 | override.vm.synced_folder "./provision", "/vagrant" 48 | override.vm.synced_folder "./data/jenkins", "/root/jenkins" 49 | 50 | # Configure Vagrant plugin, Cachier 51 | if Vagrant.has_plugin?("vagrant-cachier") 52 | # https://github.com/fgrehm/vagrant-cachier 53 | config.cache.scope = :box 54 | end 55 | 56 | # Configure Vagrant plugin, vbguest auto-upgrade 57 | if Vagrant.has_plugin?("vagrant-vbguest") 58 | # https://github.com/dotless-de/vagrant-vbguest 59 | config.vbguest.auto_update = false 60 | end 61 | end 62 | 63 | 64 | 65 | # configuration Amazon provider 66 | config.vm.provider :aws do |aws, override| 67 | 68 | # Load sensitive AWS credentials from external file, DO NOT save in Repo!!! 69 | # @see http://blog-osshive.rhcloud.com/2014/02/05/provisioning-aws-instances-with-vagrant/ 70 | require 'yaml' 71 | aws_filepath = File.dirname(__FILE__) + "/aws-config.yml" 72 | if File.exist?(aws_filepath) 73 | aws_config = YAML.load_file(aws_filepath)["aws"] 74 | else 75 | print "Error: '" + aws_filepath + "' is missing...\n" 76 | end 77 | 78 | # set AWS creds 79 | aws.access_key_id = aws_config["access_key_id"] 80 | aws.secret_access_key = aws_config["secret_access_key"] 81 | aws.keypair_name = aws_config["keypair_name"] 82 | 83 | # configure SSH... and fuck Windows file pathways... 84 | override.ssh.private_key_path = aws_config["pemfile"] 85 | override.ssh.username = "ubuntu" 86 | 87 | # use Ubuntu / Trust 64-bit HVM 88 | # @see https://cloud-images.ubuntu.com/locator/ec2/ 89 | aws.region = "us-east-1" 90 | aws.ami = "ami-fce3c696" 91 | 92 | # set instance settings 93 | # @see https://aws.amazon.com/ec2/instance-types/ 94 | aws.instance_ready_timeout = 180 95 | aws.instance_type = "t2.micro" 96 | aws.associate_public_ip = true 97 | aws.subnet_id = aws_config["subnet_id"] 98 | aws.tags = { 99 | 'Name' => 'jenkins-pipeline-demo', 100 | } 101 | # use 40GB, because we like it UUGE! 102 | aws.block_device_mapping = [ 103 | { 104 | 'DeviceName' => '/dev/xvda', 105 | 'VirtualName' => 'root', 106 | 'Ebs.VolumeSize' => 40, 107 | 'Ebs.DeleteOnTermination' => 'true' 108 | } 109 | ] 110 | 111 | # Configure file sharing using rsync. 112 | # This requires Windows users to have Cygwin or MinGW installed. 113 | # @see https://www.vagrantup.com/blog/feature-preview-vagrant-1-5-rsync.html 114 | # @see https://github.com/mitchellh/vagrant/blob/master/website/docs/source/v2/synced-folders/rsync.html.md 115 | override.vm.synced_folder "./data", "/vagrant", type: "rsync" 116 | # , disabled: true 117 | 118 | # To continuously update files uni-directionally from local host to the 119 | # remote EC2 instance, open another shell, run: 120 | # "vagrant rsync-auto" 121 | 122 | # Fix for Windows users running Cygwin: 123 | if Vagrant::Util::Platform.windows? 124 | ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin" 125 | end 126 | 127 | # disable the vbguest update plugin 128 | if Vagrant.has_plugin?("vagrant-vbguest") 129 | override.vbguest.auto_update = false 130 | end 131 | 132 | # run AWS specific steps 133 | override.vm.provision :shell, path: "./provision/bootstrap_aws.sh" 134 | end 135 | end 136 | -------------------------------------------------------------------------------- /jenkins-server/aws-config-example.yml: -------------------------------------------------------------------------------- 1 | aws: 2 | access_key_id : 'AKIAAAAAAAAAAAAAAAA' 3 | secret_access_key : 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 4 | keypair_name : 'vagrant' 5 | pemfile : '/home/user/.ssh/vagrant.pem' 6 | subnet_id : 'subnet-1a2b3c4d' 7 | -------------------------------------------------------------------------------- /jenkins-server/data/jenkins/build_python.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup Discover-Flask 4 | APP_SETTINGS="config.ProductionConfig" 5 | export APP_SETTINGS 6 | 7 | 8 | # create DB tables, set folder and file permissions 9 | cd ./www/ 10 | mkdir -p /tmp/tmp 11 | touch /tmp/tmp/sample.db 12 | chown www-data:www-data /tmp/tmp/sample.db 13 | chown www-data:www-data /tmp/tmp 14 | chmod -R 777 /tmp/tmp 15 | 16 | python db_create_users.py 17 | python db_create_posts.py 18 | 19 | 20 | 21 | # run tests 22 | pylint -f parseable project/ > pylint.out 23 | nosetests --with-xcoverage --with-xunit --all-modules --traverse-namespace --cover-package=project --cover-inclusive --cover-erase -x tests.py > /dev/null 24 | clonedigger --cpd-output -o clonedigger.xml project > /dev/null 25 | sloccount --duplicates --wide --details . | fgrep -v .svn > sloccount.sc || : 26 | 27 | exit 0; 28 | -------------------------------------------------------------------------------- /jenkins-server/data/jenkins/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 2 6 | NORMAL 7 | false 8 | 9 | true 10 | false 11 | 12 | false 13 | 14 | ${JENKINS_HOME}/workspace/${ITEM_FULLNAME} 15 | ${ITEM_ROOTDIR}/builds 16 | 17 | 18 | 19 | 20 | 0 21 | 22 | 23 | 24 | All 25 | false 26 | false 27 | 28 | 29 | 30 | All 31 | -1 32 | 33 | 34 | false 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /jenkins-server/data/jenkins/jobs/PipelineDemo/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 51 | true 52 | 53 | 54 | -------------------------------------------------------------------------------- /jenkins-server/data/jenkins/jobs/Python_Pipeline/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | 2 9 | 10 | 11 | https://github.com/apolloclark/discover-flask-vagrant 12 | 13 | 14 | 15 | 16 | */master 17 | 18 | 19 | false 20 | 21 | 22 | 23 | true 24 | false 25 | false 26 | false 27 | 28 | false 29 | 30 | 31 | sh /root/jenkins/build_python.sh 32 | 33 | 34 | 35 | 36 | **/coverage.xml 37 | false 38 | false 39 | false 40 | false 41 | false 42 | false 43 | 0 44 | true 45 | 46 | 47 | 48 | METHOD 49 | 8000000 50 | 51 | 52 | LINE 53 | 8000000 54 | 55 | 56 | CONDITIONAL 57 | 7000000 58 | 59 | 60 | 61 | 62 | 63 | 64 | METHOD 65 | 0 66 | 67 | 68 | LINE 69 | 0 70 | 71 | 72 | CONDITIONAL 73 | 0 74 | 75 | 76 | 77 | 78 | 79 | 80 | METHOD 81 | 0 82 | 83 | 84 | LINE 85 | 0 86 | 87 | 88 | CONDITIONAL 89 | 0 90 | 91 | 92 | 93 | ASCII 94 | 95 | 96 | **/nosetests.xml 97 | false 98 | 99 | 1.0 100 | 101 | 102 | **/sloccount.sc 103 | 104 | false 105 | 0 106 | false 107 | 108 | 109 | 110 | 111 | 112 | 113 | checkstyle 114 | 115 | checkstyle 116 | 10 117 | 999 118 | 999 119 | false 120 | 121 | 122 | 123 | 124 | codenarc 125 | 126 | codenarc 127 | 10 128 | 999 129 | 999 130 | false 131 | 132 | 133 | 134 | 135 | cpd 136 | 137 | cpd 138 | 10 139 | 999 140 | 999 141 | false 142 | 143 | 144 | 145 | 146 | cpplint 147 | 148 | cpplint 149 | 10 150 | 999 151 | 999 152 | false 153 | 154 | 155 | 156 | 157 | csslint 158 | 159 | csslint 160 | 10 161 | 999 162 | 999 163 | false 164 | 165 | 166 | 167 | 168 | findbugs 169 | 170 | findbugs 171 | 10 172 | 999 173 | 999 174 | false 175 | 176 | 177 | 178 | 179 | fxcop 180 | 181 | fxcop 182 | 10 183 | 999 184 | 999 185 | false 186 | 187 | 188 | 189 | 190 | gendarme 191 | 192 | gendarme 193 | 10 194 | 999 195 | 999 196 | false 197 | 198 | 199 | 200 | 201 | jcreport 202 | 203 | jcreport 204 | 10 205 | 999 206 | 999 207 | false 208 | 209 | 210 | 211 | 212 | jslint 213 | 214 | jslint 215 | 10 216 | 999 217 | 999 218 | false 219 | 220 | 221 | 222 | 223 | pep8 224 | 225 | pep8 226 | 10 227 | 999 228 | 999 229 | false 230 | 231 | 232 | 233 | 234 | perlcritic 235 | 236 | perlcritic 237 | 10 238 | 999 239 | 999 240 | false 241 | 242 | 243 | 244 | 245 | pmd 246 | 247 | pmd 248 | 10 249 | 999 250 | 999 251 | false 252 | 253 | 254 | 255 | 256 | pylint 257 | 258 | pylint 259 | 10 260 | 999 261 | 999 262 | false 263 | **/pylint.out 264 | 265 | 266 | 267 | simian 268 | 269 | simian 270 | 10 271 | 999 272 | 999 273 | false 274 | 275 | 276 | 277 | 278 | stylecop 279 | 280 | stylecop 281 | 10 282 | 999 283 | 999 284 | false 285 | 286 | 287 | 288 | 289 | 100 290 | 291 | 292 | default 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /jenkins-server/data/jenkins/jobs/Python_Pipeline/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | Flask-Bcrypt==0.6.0 3 | Flask-Login==0.2.11 4 | Flask-Migrate==1.2.0 5 | Flask-SQLAlchemy==1.0 6 | Flask-Script==2.0.5 7 | Flask-Testing==0.4.2 8 | Flask-WTF==0.10.2 9 | Jinja2==2.7.3 10 | Mako==1.0.0 11 | MarkupSafe==0.23 12 | SQLAlchemy==0.9.4 13 | WTForms==2.0.1 14 | Werkzeug==0.9.6 15 | alembic==0.6.6 16 | gunicorn==19.0.0 17 | itsdangerous==0.24 18 | psycopg2==2.5.3 19 | py-bcrypt==0.4 20 | wsgiref==0.1.2 -------------------------------------------------------------------------------- /jenkins-server/provision/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # update system 7 | apt-get update 8 | apt-get upgrade -y 9 | apt-get install -y wget curl unzip unzip wget daemon python-setuptools \ 10 | software-properties-common git-core 11 | 12 | 13 | 14 | 15 | 16 | # Install OpenJDK 8 17 | 18 | # Sets language to UTF8 : this works in pretty much all cases 19 | locale-gen en_US.UTF-8 20 | 21 | # add repo, update, install 22 | add-apt-repository -y ppa:openjdk-r/ppa 2>&1 23 | apt-get update 24 | apt-get install -y openjdk-8-jre-headless 25 | export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/" 26 | apt-get install -y ca-certificates 27 | /var/lib/dpkg/info/ca-certificates-java.postinst configure 28 | 29 | 30 | 31 | 32 | 33 | # Install Jenkins 34 | # @see https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu 35 | wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | \ 36 | apt-key add - 37 | echo "deb https://pkg.jenkins.io/debian binary/" | \ 38 | sudo tee /etc/apt/sources.list.d/jenkins.list 39 | add-apt-repository -y ppa:openjdk-r/ppa 2>&1 40 | apt-get update 41 | apt-get install -y jenkins 42 | 43 | # install a specific version of Jenkins 44 | # dpkg --install /vagrant/jenkins_1.642_all.deb 45 | # service jenkins restart 46 | 47 | 48 | 49 | # Install Jenkins plugins 50 | # @see http://updates.jenkins-ci.org/download/plugins/ 51 | # @see /var/lib/jenkins/plugins/ 52 | # @see https://github.com/jenkinsci/workflow-aggregator-plugin/blob/master/demo/plugins.txt 53 | 54 | # install the Jenkins plugins 55 | echo "INFO: Installing Jenkins plugins..." 56 | mkdir -p /var/lib/jenkins/plugins/ 57 | chmod -R 0777 /var/lib/jenkins/plugins 58 | /vagrant/jenkins_install_plugins.sh /vagrant/jenkins_plugins.txt 59 | 60 | # clear the logs, set folder permissions, restart 61 | chmod -R 0777 /var/lib/jenkins/plugins 62 | rm -f /var/log/jenkins/jenkins.log 63 | echo "INFO: Done installing Jenkins plugins." 64 | -------------------------------------------------------------------------------- /jenkins-server/provision/bootstrap_aws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # Autoresize the EC2 root EBS partition, if needed 7 | if [[ $(df -h | grep 'xvda1') ]]; then 8 | /sbin/parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100% 9 | resize2fs /dev/xvda1 10 | fi 11 | -------------------------------------------------------------------------------- /jenkins-server/provision/bootstrap_copy_project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # copy over project setup 7 | echo "INFO: Copying over Pre-configured Jobs." 8 | mkdir -p /var/lib/jenkins/jobs/ 9 | cp -rf /root/jenkins/. /var/lib/jenkins/ 10 | chmod -R 777 /var/lib/jenkins/jobs/ 11 | chown -R jenkins:jenkins /var/lib/jenkins 12 | 13 | # print the generated password 14 | echo -e "Jenkins Password:" 15 | cat /var/lib/jenkins/secrets/initialAdminPassword 16 | -------------------------------------------------------------------------------- /jenkins-server/provision/bootstrap_python.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the environment to be fully automated 4 | export DEBIAN_FRONTEND="noninteractive" 5 | 6 | # Install various dependencies 7 | apt-get -y install build-essential libreadline-gplv2-dev libncursesw5-dev \ 8 | libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev sshpass \ 9 | sloccount sqlite3 libsqlite3-dev 10 | 11 | 12 | 13 | # Install Python 14 | echo "INFO: Installing Python..." 15 | apt-get -y install python2.7 python-pip python-dev libpq-dev libffi-dev \ 16 | libssl-dev 17 | pip install --upgrade pip > /dev/null 2>&1 18 | # @see https://pip.pypa.io/en/latest/reference/pip.html 19 | 20 | # Install code quality tools 21 | pip install -qqq pylint > /dev/null 2>&1 22 | pip install --quiet mock coverage nose nosexcover clonedigger ndg-httpsclient \ 23 | pyasn1 > /dev/null 2>&1 24 | 25 | # Install Flask requirements 26 | pip install -qqq -r /vagrant/jobs/Python_Pipeline/requirements.txt > /dev/null 2>&1 27 | echo "INFO: Done installing Python." 28 | 29 | # create folder for SQLite DB 30 | mkdir -p /tmp/tmp 31 | touch /tmp/tmp/sample.db 32 | chown www-data:www-data /tmp/tmp/sample.db 33 | chown www-data:www-data /tmp/tmp 34 | chmod -R 777 /tmp/tmp 35 | 36 | 37 | 38 | 39 | 40 | # Install Jenkins Python plugins 41 | # @see http://updates.jenkins-ci.org/download/plugins/ 42 | # @see /var/lib/jenkins/plugins/ 43 | echo "INFO: Installing Jenkins plugins..." 44 | mkdir -p /var/lib/jenkins/plugins/ 45 | chown -R jenkins:jenkins /var/lib/jenkins/plugins 46 | /vagrant/jenkins_install_plugins.sh /vagrant/jenkins_plugins_python.txt 47 | chown -R jenkins:jenkins /var/lib/jenkins/plugins 48 | 49 | # clear the logs, set folder permissions, restart 50 | rm -f /var/log/jenkins/jenkins.log 51 | echo "INFO: Done installing Jenkins Python plugins." 52 | -------------------------------------------------------------------------------- /jenkins-server/provision/jenkins_install_plugins.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # @see https://github.com/jenkinsci/docker/blob/master/plugins.sh 4 | # Parse a support-core plugin -style txt file as specification for jenkins plugins to be installed 5 | # in the reference directory, so user can define a derived Docker image with just : 6 | # 7 | # FROM jenkins 8 | # COPY plugins.txt /plugins.txt 9 | # RUN /usr/local/bin/plugins.sh /plugins.txt 10 | # 11 | 12 | set -e 13 | 14 | REF=/var/lib/jenkins/plugins 15 | JENKINS_UC_DOWNLOAD="http://updates.jenkins-ci.org/download" 16 | mkdir -p $REF 17 | 18 | while read spec || [ -n "$spec" ]; do 19 | plugin=(${spec//:/ }); 20 | [[ ${plugin[0]} =~ ^# ]] && continue 21 | [[ ${plugin[0]} =~ ^\s*$ ]] && continue 22 | [[ -z ${plugin[1]} ]] && plugin[1]="latest" 23 | echo "${JENKINS_UC_DOWNLOAD}/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi" 24 | 25 | if [ -z "$JENKINS_UC_DOWNLOAD" ]; then 26 | JENKINS_UC_DOWNLOAD=$JENKINS_UC/download 27 | fi 28 | 29 | curl -sSL -f ${JENKINS_UC_DOWNLOAD}/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi -o $REF/${plugin[0]}.hpi 30 | done < $1 -------------------------------------------------------------------------------- /jenkins-server/provision/jenkins_plugins.txt: -------------------------------------------------------------------------------- 1 | ace-editor:1.1 2 | branch-api:2.0.11 3 | cloudbees-folder:6.1.2 4 | credentials:2.1.16 5 | display-url-api:2.0 6 | durable-task:1.14 7 | git-client:2.5.0 8 | git:3.5.1 9 | git-server:1.7 10 | github-api:1.86 11 | handlebars:1.1.1 12 | icon-shim:2.0.3 13 | jackson2-api:2.7.3 14 | jquery-detached:1.2.1 15 | junit:1.21 16 | mailer:1.20 17 | matrix-project:1.11 18 | mock-slave:1.10 19 | momentjs:1.1.1 20 | pipeline-build-step:2.5.1 21 | pipeline-graph-analysis:1.5 22 | pipeline-input-step:2.8 23 | pipeline-milestone-step:1.3.1 24 | pipeline-rest-api:2.9 25 | pipeline-stage-step:2.2 26 | pipeline-stage-view:2.9 27 | scm-api:2.2.2 28 | script-security:1.34 29 | ssh-credentials:1.13 30 | structs:1.10 31 | workflow-aggregator:2.5 32 | workflow-api:2.20 33 | workflow-basic-steps:2.6 34 | workflow-cps:2.40 35 | workflow-cps-global-lib:2.9 36 | workflow-durable-task-step:2.15 37 | workflow-job:2.14.1 38 | workflow-multibranch:2.16 39 | workflow-scm-step:2.6 40 | workflow-step-api:2.12 41 | workflow-support:2.14 -------------------------------------------------------------------------------- /jenkins-server/provision/jenkins_plugins_python.txt: -------------------------------------------------------------------------------- 1 | cobertura:1.11 2 | javadoc:1.4 3 | maven-plugin:2.17 4 | performance:3.3 5 | sloccount:1.21 6 | token-macro:2.3 7 | violations:0.7.11 -------------------------------------------------------------------------------- /preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apolloclark/jenkins/7d81ef4fa615a1404b6263222c470431b5db863b/preview.jpg --------------------------------------------------------------------------------