This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb-extras.git


The following commit(s) were added to refs/heads/master by this push:
     new e96689e  chore: Added a Jenkinsfile for building on Apache's Jenkins
e96689e is described below

commit e96689e9508f0d8d178d34181efe6bd0641f938a
Author: Christofer Dutz <[email protected]>
AuthorDate: Thu Apr 18 13:11:16 2024 +0200

    chore: Added a Jenkinsfile for building on Apache's Jenkins
---
 Jenkinsfile | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 jenkins.pom |  68 +++++++++++++++++++++
 2 files changed, 267 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..c206b15
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,199 @@
+#!groovy
+
+/*
+ * 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.
+ */
+
+pipeline {
+
+    agent {
+        node {
+            label 'ubuntu'
+        }
+    }
+
+    environment {
+        // Testfails will be handled by the jenkins junit steps and mark the 
build as unstable.
+        MVN_TEST_FAIL_IGNORE = '-Dmaven.test.failure.ignore=true'
+    }
+
+    tools {
+        maven 'maven_3_latest'
+        jdk 'jdk_11_latest'
+    }
+
+    options {
+        timeout(time: 8, unit: 'HOURS')
+        // When we have test-fails e.g. we don't need to run the remaining 
steps
+        skipStagesAfterUnstable()
+    }
+
+    stages {
+        stage('Initialization') {
+            steps {
+                echo 'Building Branch: ' + env.BRANCH_NAME
+                echo 'Using PATH = ' + env.PATH
+            }
+        }
+
+        stage('Checkout') {
+            steps {
+                echo 'Checking out branch ' + env.BRANCH_NAME
+                checkout scm
+            }
+        }
+
+        stage('Build and UT') {
+            when {
+                expression {
+                    env.BRANCH_NAME ==~ "(master)|(rel/.*) |(jenkins-.*)"
+                }
+            }
+            steps {
+                echo 'Building and Unit Test...'
+                sh "mvn ${MVN_TEST_FAIL_IGNORE} clean install -DskipITs"
+            }
+            post {
+                always {
+                    junit(testResults: '**/surefire-reports/*.xml', 
allowEmptyResults: true)
+                    junit(testResults: '**/failsafe-reports/*.xml', 
allowEmptyResults: true)
+                }
+            }
+        }
+
+        stage('Integration Test') {
+            when {
+                expression {
+                    env.BRANCH_NAME ==~ "(master)|(rel/.*) |(jenkins-.*)"
+                }
+            }
+            steps {
+                echo 'Integration Test...'
+                sh "mvn ${MVN_TEST_FAIL_IGNORE} verify -P 
ClusterIT,with-integration-tests -pl integration-test -am -DskipUTs 
-DintegrationTest.threadCount=3 -DintegrationTest.forkCount=3"
+            }
+            post {
+                always {
+                    junit(testResults: '**/surefire-reports/*.xml', 
allowEmptyResults: true)
+                    junit(testResults: '**/failsafe-reports/*.xml', 
allowEmptyResults: true)
+                }
+                failure {
+                    archiveArtifacts 'integration-test/target/cluster-logs/**'
+                    archiveArtifacts 'integration-test/target/pipeIT-logs/**'
+                }
+            }
+        }
+
+        stage('Deploy Prepare') {
+            when {
+                branch 'master'
+            }
+            when {
+                expression {
+                    env.BRANCH_NAME ==~ "(master)|(rel/.*)"
+                }
+            }
+            steps {
+                echo 'Deploy Prepare'
+                // We'll deploy to a relative directory so we can
+                // deploy new versions only if the entire build succeeds
+                sh "mvn -T 1C 
-DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir 
clean deploy -DskipTests"
+            }
+            post {
+                always {
+                    junit(testResults: '**/surefire-reports/*.xml', 
allowEmptyResults: true)
+                    junit(testResults: '**/failsafe-reports/*.xml', 
allowEmptyResults: true)
+                }
+            }
+        }
+
+        stage('Deploy') {
+            when {
+                expression {
+                    env.BRANCH_NAME ==~ "(master)|(rel/.*)"
+                }
+            }
+            steps {
+                echo 'Deploying'
+                // Deploy the artifacts using the wagon-maven-plugin.
+                sh 'mvn -f jenkins.pom -X -P deploy-snapshots wagon:upload'
+            }
+        }
+
+        stage('Cleanup') {
+            steps {
+                echo 'Cleaning up the workspace'
+                deleteDir()
+            }
+        }
+    }
+
+    // Send out notifications on unsuccessful builds.
+    post {
+        // If this build failed, send an email to the list.
+        failure {
+            script {
+                if(env.BRANCH_NAME == "master") {
+                    emailext(
+                        subject: "[BUILD-FAILURE]: Job '${env.JOB_NAME} 
[${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'",
+                        body: """
+BUILD-FAILURE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] 
[${env.BUILD_NUMBER}]':
+
+Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} 
[${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]</a>"
+""",
+                        to: "[email protected]"
+                    )
+                }
+            }
+        }
+
+        // If this build didn't fail, but there were failing tests, send an 
email to the list.
+        unstable {
+            script {
+                if(env.BRANCH_NAME == "master") {
+                    emailext(
+                        subject: "[BUILD-UNSTABLE]: Job '${env.JOB_NAME} 
[${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'",
+                        body: """
+BUILD-UNSTABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] 
[${env.BUILD_NUMBER}]':
+
+Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} 
[${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]</a>"
+""",
+                        to: "[email protected]"
+                    )
+                }
+            }
+        }
+
+        // Send an email, if the last build was not successful and this one is.
+        success {
+            script {
+                if ((env.BRANCH_NAME == "master") && 
(currentBuild.previousBuild != null) && (currentBuild.previousBuild.result != 
'SUCCESS')) {
+                    emailext (
+                        subject: "[BUILD-STABLE]: Job '${env.JOB_NAME} 
[${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'",
+                        body: """
+BUILD-STABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]':
+
+Is back to normal.
+""",
+                        to: "[email protected]"
+                    )
+                }
+            }
+        }
+    }
+
+}
diff --git a/jenkins.pom b/jenkins.pom
new file mode 100644
index 0000000..9ab70fa
--- /dev/null
+++ b/jenkins.pom
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>32</version>
+    </parent>
+
+    <groupId>org.apache.iotdb</groupId>
+    <artifactId>iotdb-extras-jenkins-tools</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <name>IoTDB Extras: Jenkins Tools</name>
+    <description>Set of helpers to do individual tasks only needed on our 
Jenkins build.</description>
+
+    <profiles>
+        <!--
+            This profile is used to deploy all the artifacts in the
+            'local-snapshots-dir' to Apache's SNAPSHOT repo.
+        -->
+        <profile>
+            <id>deploy-snapshots</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>wagon-maven-plugin</artifactId>
+                        <version>2.0.0</version>
+                        <configuration>
+                            
<fromDir>${project.basedir}/local-snapshots-dir</fromDir>
+                            <includes>**</includes>
+                            <excludes>library-udf</excludes>
+                            <serverId>apache.snapshots.https</serverId>
+                            <url>${distMgmtSnapshotsUrl}</url>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>

Reply via email to