forked from jenkinsci/docker-workflow-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7177e66
Showing
53 changed files
with
3,575 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
target | ||
work | ||
|
||
demo/Dockerfile | ||
demo/.cache/ | ||
# TODO: remove once this plugin is released | ||
demo/JENKINS_HOME/plugins/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2015, CloudBees, Inc. | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CloudBees Docker Workflow Plugin | ||
===================================== | ||
|
||
Jenkins plugin, which allows building and using Docker containers from workflows. | ||
|
||
Summary | ||
--- | ||
The plugin provides: | ||
* DSL commands for building and running Docker images | ||
* Wrapper blocks defining Docker server and registry endpoints | ||
* Actions displaying images related to the build (to be merged with docker-commons) | ||
* etc. | ||
|
||
More info is available on the plugin's [Wiki page](http://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Workflow+Plugin) | ||
|
||
Demo | ||
--- | ||
The plugin has a Docker-based demo. See the [demo README](demo/README.md) page for setup and launch guidelines. | ||
|
||
License | ||
--- | ||
[MIT License](http://opensource.org/licenses/MIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
## | ||
# The MIT License | ||
# | ||
# Copyright (c) 2015, CloudBees, Inc. | ||
# | ||
# 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: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# 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. | ||
## | ||
|
||
FROM jenkinsci/workflow-demo:1.7-alpha-1 | ||
|
||
############################################################### | ||
# Docker in Docker https://github.com/jpetazzo/dind | ||
|
||
# Install Docker from Docker Inc. repositories. | ||
RUN curl -sSL https://get.docker.com/ubuntu/ | sh | ||
|
||
# Install the magic wrapper. | ||
ADD wrapdocker /usr/local/bin/wrapdocker | ||
RUN chmod +x /usr/local/bin/wrapdocker | ||
|
||
# Define additional metadata for our image. | ||
VOLUME /var/lib/docker | ||
|
||
# | ||
############################################################### | ||
|
||
COPY workflow-reg-proxy.conf /tmp/files/regup/workflow-reg-proxy.conf | ||
COPY gen-security-data.sh /usr/local/bin/gen-security-data.sh | ||
RUN /usr/local/bin/gen-security-data.sh /tmp/files/regup/sec | ||
RUN apt-get install -y apparmor | ||
COPY run-demo.sh /usr/local/bin/run-demo.sh | ||
|
||
COPY plugins.txt /tmp/files/ | ||
RUN /usr/local/bin/plugins.sh /tmp/files/plugins.txt | ||
RUN touch /usr/share/jenkins/ref/plugins/credentials.jpi.pinned | ||
|
||
ADD JENKINS_HOME /usr/share/jenkins/ref | ||
|
||
# TODO until https://github.com/jenkinsci/docker/pull/89 is picked up upstream, shut up please: | ||
RUN perl -i -p -e 's/ *echo.+//g' /usr/local/bin/jenkins.sh | ||
|
||
# wrapdocker has been modified to launch Jenkins via the installed run.sh script | ||
CMD ["wrapdocker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
## | ||
# The MIT License | ||
# | ||
# Copyright (c) 2015, CloudBees, Inc. | ||
# | ||
# 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: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# 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. | ||
## | ||
|
||
FROM jenkinsci/workflow-demo:SNAPSHOT | ||
|
||
############################################################### | ||
# Docker in Docker https://github.com/jpetazzo/dind | ||
|
||
# Install Docker from Docker Inc. repositories. | ||
RUN curl -sSL https://get.docker.com/ubuntu/ | sh | ||
|
||
# Install the magic wrapper. | ||
ADD wrapdocker /usr/local/bin/wrapdocker | ||
RUN chmod +x /usr/local/bin/wrapdocker | ||
|
||
# Define additional metadata for our image. | ||
VOLUME /var/lib/docker | ||
|
||
# | ||
############################################################### | ||
|
||
RUN apt-get install -y apparmor apache2-utils | ||
|
||
COPY workflow-reg-proxy.conf /tmp/files/regup/workflow-reg-proxy.conf | ||
COPY gen-security-data.sh /usr/local/bin/gen-security-data.sh | ||
RUN /usr/local/bin/gen-security-data.sh /tmp/files/regup/sec | ||
COPY run-demo.sh /usr/local/bin/run-demo.sh | ||
|
||
COPY plugins.txt /tmp/files/ | ||
RUN /usr/local/bin/plugins.sh /tmp/files/plugins.txt | ||
RUN touch /usr/share/jenkins/ref/plugins/credentials.jpi.pinned | ||
|
||
ADD JENKINS_HOME /usr/share/jenkins/ref | ||
|
||
# TODO until https://github.com/jenkinsci/docker/pull/89 is picked up upstream, shut up please: | ||
RUN perl -i -p -e 's/ *echo.+//g' /usr/local/bin/jenkins.sh | ||
|
||
# wrapdocker has been modified to launch Jenkins via the installed run.sh script | ||
CMD ["wrapdocker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<hudson> | ||
<disabledAdministrativeMonitors/> | ||
<version>1.0</version> | ||
<numExecutors>2</numExecutors> | ||
<mode>NORMAL</mode> | ||
<useSecurity>true</useSecurity> | ||
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/> | ||
<securityRealm class="hudson.security.SecurityRealm$None"/> | ||
<disableRememberMe>false</disableRememberMe> | ||
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/> | ||
<workspaceDir>${ITEM_ROOTDIR}/workspace</workspaceDir> | ||
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir> | ||
<jdks/> | ||
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/> | ||
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/> | ||
<clouds/> | ||
<slaves/> | ||
<scmCheckoutRetryCount>0</scmCheckoutRetryCount> | ||
<views> | ||
<hudson.model.AllView> | ||
<owner class="hudson" reference="../../.."/> | ||
<name>All</name> | ||
<filterExecutors>false</filterExecutors> | ||
<filterQueue>false</filterQueue> | ||
<properties class="hudson.model.View$PropertyList"/> | ||
</hudson.model.AllView> | ||
</views> | ||
<primaryView>All</primaryView> | ||
<slaveAgentPort>0</slaveAgentPort> | ||
<label></label> | ||
<nodeProperties/> | ||
<globalNodeProperties/> | ||
</hudson> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin="[email protected]"> | ||
<domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash"> | ||
<entry> | ||
<com.cloudbees.plugins.credentials.domains.Domain> | ||
<specifications/> | ||
</com.cloudbees.plugins.credentials.domains.Domain> | ||
<java.util.concurrent.CopyOnWriteArrayList> | ||
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl> | ||
<scope>GLOBAL</scope> | ||
<id>docker-registry-login</id> | ||
<description></description> | ||
<username>workflowuser</username> | ||
<password>123123123</password> | ||
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl> | ||
</java.util.concurrent.CopyOnWriteArrayList> | ||
</entry> | ||
</domainCredentialsMap> | ||
</com.cloudbees.plugins.credentials.SystemCredentialsProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<flow-definition> | ||
<actions/> | ||
<description>Demonstrates Jenkins Workflow integration with Docker based on
 | ||
<a href="https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Workflow+Plugin">CloudBees Docker Workflow</a> plugin | ||
</description> | ||
<keepDependencies>false</keepDependencies> | ||
<properties/> | ||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition"> | ||
<script>node { | ||
def maven32 = docker.image('maven:3.2-jdk-7-onbuild'); // https://registry.hub.docker.com/_/maven/; | ||
|
||
stage 'Mirror' | ||
// First make sure the slave has this image. | ||
// (If you could set your registry below to mirror Docker Hub, | ||
// this would be unnecessary as maven32.inside would pull the image.) | ||
maven32.pull() | ||
// We are pushing to a private secure docker registry in this demo. | ||
// 'docker-registry-login' is the username/password credentials ID as defined in Jenkins Credentials. | ||
// This is used to authenticate the docker client to the registry. | ||
docker.withRegistry('https://docker.example.com/', 'docker-registry-login') { | ||
|
||
stage 'Build' | ||
|
||
// spin up a Maven container to build the petclinic app from source | ||
// (we are only using -v here to share the Maven local repository across demo runs; otherwise would set localRepository=${pwd}/m2repo) | ||
maven32.inside('-v /m2repo:/m2repo') { | ||
// Check out the source code. | ||
git 'https://github.com/tfennelly/spring-petclinic.git' | ||
|
||
// Set up a shared Maven repo so we don't need to download all dependencies on every build. | ||
writeFile file: 'settings.xml', text: '<settings><localRepository>/m2repo</localRepository></settings>' | ||
// Build with Maven settings.xml file that specs the local Maven repo. | ||
sh 'mvn -B -s settings.xml clean install -DskipTests' | ||
|
||
// The app .war and Dockerfile are now available in the workspace. See below. | ||
} | ||
|
||
stage 'Bake Docker image' | ||
// use the spring-petclinic Dockerfile (see above 'maven32.inside()' block) | ||
// to build container that can run the app. The Dockerfile is in the cwd of the active workspace | ||
// (see above maven32.inside() block), so we pass '.' as the build PATH param. The Dockerfile | ||
// (see https://github.com/tfennelly/spring-petclinic/blob/master/Dockerfile) expects the petclinic.war | ||
// file to be in the 'target' dir of the workspace, which will be the case. | ||
def pcImg = docker.build("examplecorp/spring-petclinic:${env.BUILD_TAG}", '.') | ||
|
||
// Let's tag and push the newly built image. Will tag using the image name provided | ||
// in the 'docker.build' call above (which included the build number on the tag). | ||
pcImg.push(); | ||
|
||
stage 'Test Image' | ||
// Run the petclinic app in its own docker container | ||
pcImg.withRun {petclinic -> | ||
// Spin up a maven test container, linking it to the petclinic app container allowing | ||
// the maven tests to fire HTTP requests between the containers. | ||
maven32.inside("-v /m2repo:/m2repo --link=${petclinic.id}:petclinic") { | ||
git 'https://github.com/tfennelly/spring-petclinic-tests.git' | ||
|
||
writeFile file: 'settings.xml', text: '<settings><localRepository>/m2repo</localRepository></settings>' | ||
sh 'mvn -B -s settings.xml clean package' | ||
} | ||
} | ||
|
||
stage name: 'Promote Image', concurrency: 1 | ||
// All the tests passed. We can now retag and push the 'latest' image | ||
pcImg.push('latest'); | ||
} | ||
}</script> | ||
<sandbox>true</sandbox> | ||
</definition> | ||
<triggers/> | ||
</flow-definition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## | ||
# The MIT License | ||
# | ||
# Copyright (c) 2015, CloudBees, Inc. | ||
# | ||
# 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: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# 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. | ||
## | ||
TAG=$(shell cat workflow-version.txt) | ||
IMAGE=jenkinsci/docker-workflow-demo | ||
CACHE=$(shell pwd)/.cache | ||
|
||
# | ||
# Build from the Dockerfile_release Dockerfile | ||
# Only run this target when the project pom dependencies are RELEASED dependencies. | ||
# | ||
# TODO: Remove and delete ./get-snapshots.sh once this plugin is released. See comment in ./get-snapshots.sh | ||
# | ||
build: | ||
./get-snapshots.sh | ||
docker build -t $(IMAGE):$(TAG) -f Dockerfile_release . | ||
|
||
# | ||
# Build from the Dockerfile_release Dockerfile | ||
# Only run this target when the project pom dependencies are SNAPSHOT dependencies. | ||
# | ||
# TODO: Remove and delete ./get-snapshots.sh once this plugin is released. See comment in ./get-snapshots.sh | ||
# | ||
build-snapshot: | ||
./get-snapshots.sh | ||
docker build -t $(IMAGE):SNAPSHOT -f Dockerfile_snapshot . | ||
|
||
# | ||
# To connect a Java debugger to the Jenkins instance running in the docker container, simply add the following | ||
# options to the "docker run" command (just after the port mappings): | ||
# | ||
# -p 5500:5500 -e JAVA_OPTS=-Xrunjdwp:transport=dt_socket,server=y,address=5500,suspend=n | ||
# | ||
# If using boot2docker, you need to tell your remote debugger to use the boot2docker VM ip (ala boot2docker ip). | ||
# | ||
|
||
run: | ||
docker run --rm -p 8080:8080 -p 8081:8081 -p 8022:22 -p 18080:18080 --add-host=docker.example.com:127.0.0.1 -ti --privileged $(IMAGE):$(TAG) | ||
|
||
run-snapshot: | ||
docker run --rm -p 8080:8080 -p 8081:8081 -p 8022:22 -p 18080:18080 --add-host=docker.example.com:127.0.0.1 -ti --privileged $(IMAGE):SNAPSHOT | ||
|
||
run-snapshot-cached: | ||
mkdir -p $(CACHE)/docker | ||
sudo rm -rf $(CACHE)/docker/containers $(CACHE)/docker/linkgraph.db | ||
mkdir -p $(CACHE)/maven | ||
docker run --rm -p 8080:8080 -p 8081:8081 -p 8022:22 -p 18080:18080 --add-host=docker.example.com:127.0.0.1 -ti --privileged -v $(CACHE)/docker:/var/lib/docker -v $(CACHE)/maven:/m2repo $(IMAGE):SNAPSHOT | ||
|
||
clean: | ||
rm -rf JENKINS_HOME/plugins | ||
|
||
push: | ||
docker push $(IMAGE):SNAPSHOT |
Oops, something went wrong.