You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2018/09/25 14:24:35 UTC

[1/2] brooklyn git commit: Jenkins: use pipeline, and don’t bind-mount .m2

Repository: brooklyn
Updated Branches:
  refs/heads/master 3af021d73 -> 4b9d577cf


Jenkins: use pipeline, and don’t bind-mount .m2

Project: http://git-wip-us.apache.org/repos/asf/brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn/commit/d1280c84
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn/tree/d1280c84
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn/diff/d1280c84

Branch: refs/heads/master
Commit: d1280c84bb88ccb9b99ccaf3faa0ce0583b36a61
Parents: 3af021d
Author: Aled Sage <al...@gmail.com>
Authored: Tue Sep 25 15:21:49 2018 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Sep 25 15:21:49 2018 +0100

----------------------------------------------------------------------
 Dockerfile  |  6 ++++-
 Jenkinsfile | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.md   | 17 +++++++++---
 3 files changed, 100 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn/blob/d1280c84/Dockerfile
----------------------------------------------------------------------
diff --git a/Dockerfile b/Dockerfile
index 95600c0..6214f3a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -37,4 +37,8 @@ RUN apt-get update && apt-get install -y \
     dpkg \
     pkg-config \
     nasm \
-    gcc \
+    gcc
+
+# For mvn-build
+RUN mkdir -p /var/maven/.m2/ && chmod -R 777 /var/maven/
+ENV MAVEN_CONFIG=/var/maven/.m2

http://git-wip-us.apache.org/repos/asf/brooklyn/blob/d1280c84/Jenkinsfile
----------------------------------------------------------------------
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..0fcd6d3
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+node(label: 'ubuntu') {
+    catchError {
+        def environmentDockerImage
+
+        def dockerTag = env.BUILD_TAG.replace('%2F', '-')
+
+        withEnv(["DOCKER_TAG=${dockerTag}"]) {
+            stage('Clone repository') {
+                checkout scm
+            }
+
+            stage('Prepare environment') {
+                echo 'Creating maven cache ...'
+                sh 'mkdir -p ${WORKSPACE}/.m2'
+                sh 'git submodule update --remote --merge --recursive'
+                echo 'Building docker image for test environment ...'
+                environmentDockerImage = docker.build('brooklyn:${DOCKER_TAG}')
+            }
+
+            stage('Run tests') {
+                environmentDockerImage.inside('-i --rm --name brooklyn-${DOCKER_TAG} -u 910:910 --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
+                    sh 'mvn clean install -Duser.home=/var/maven -Duser.name=$(id -un 910)'
+                }
+            }
+
+            // Conditional stage to deploy artifacts, when not building a PR
+            if (env.CHANGE_ID == null) {
+                stage('Deploy artifacts') {
+                    environmentDockerImage.inside('-i --rm --name brooklyn-${DOCKER_TAG} -u 910:910 --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
+                        sh 'mvn deploy -DskipTests -Duser.home=/var/maven -Duser.name=$(id -un 910)'
+                    }
+                }
+            }
+        }
+    }
+
+    // ---- Post actions steps, to always perform ----
+
+    stage('Publish test results') {
+        // Publish JUnit results
+        junit allowEmptyResults: true, testResults: '**/target/surefire-reports/junitreports/*.xml'
+
+        // Publish TestNG results
+        step([
+            $class: 'Publisher',
+            reportFilenamePattern: '**/testng-results.xml'
+        ])
+    }
+
+    // Conditional stage, when not building a PR
+    if (env.CHANGE_ID == null) {
+        stage('Send notifications') {
+            // Send email notifications
+            step([
+                $class: 'Mailer',
+                notifyEveryUnstableBuild: true,
+                recipients: 'dev@brooklyn.apache.org',
+                sendToIndividuals: false
+            ])
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn/blob/d1280c84/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index b4efce8..c0dc0ae 100644
--- a/README.md
+++ b/README.md
@@ -15,14 +15,14 @@ where you'll find:
 
 ### Quick Start
 
-This is the uber-repo. To build the entire codebase, 
+This is the uber-repo. To build the entire codebase,
 get this project and its sub-modules:
 
     git clone http://github.com/apache/brooklyn/
     cd brooklyn
     git submodule init
     git submodule update --remote --merge --recursive
-    
+
 And then, with jdk 1.8+ and maven 3.1+ installed:
 
     mvn clean install -Dno-go-client -Dno-rpm -Dno-deb
@@ -32,7 +32,18 @@ alternative: a docker container to build this project:
 
 ```bash
 docker build -t brooklyn .
-docker run -i --rm --name brooklyn -v ${HOME}/.m2:/root/.m2 -v ${PWD}:/usr/build -w /usr/build brooklyn mvn clean install
+docker run -i --rm --name brooklyn -u $(id -u):$(id -g) \
+      --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly \
+      -v ${PWD}:/usr/build -w /usr/build \
+      brooklyn mvn clean install -Duser.home=/var/maven -Duser.name=$(id -un)
+```
+
+You can speed this up by using your local .m2 cache:
+```bash
+docker run -i --rm --name brooklyn -u $(id -u):$(id -g) \
+      -v ${HOME}/.m2:/var/maven/.m2 \
+      -v ${PWD}:/usr/build -w /usr/build \
+      brooklyn mvn clean install -Duser.home=/var/maven -Duser.name=$(id -un)
 ```
 
 The results are in `brooklyn-dist/dist/target/`, including a tar and a zip.


[2/2] brooklyn git commit: This closes #21

Posted by al...@apache.org.
This closes #21


Project: http://git-wip-us.apache.org/repos/asf/brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn/commit/4b9d577c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn/tree/4b9d577c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn/diff/4b9d577c

Branch: refs/heads/master
Commit: 4b9d577cf4b12ef82ee04ba681c7f4a1409d50c9
Parents: 3af021d d1280c8
Author: Aled Sage <al...@gmail.com>
Authored: Tue Sep 25 15:24:18 2018 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Sep 25 15:24:18 2018 +0100

----------------------------------------------------------------------
 Dockerfile  |  6 ++++-
 Jenkinsfile | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.md   | 17 +++++++++---
 3 files changed, 100 insertions(+), 4 deletions(-)
----------------------------------------------------------------------