You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2021/01/25 14:24:04 UTC

[uima-build-jenkins-shared-library] branch main created (now b9ab65c)

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

rec pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/uima-build-jenkins-shared-library.git.


      at b9ab65c  [UIMA-6307] Centralize Jenkins pipelines

This branch includes the following new commits:

     new b9ab65c  [UIMA-6307] Centralize Jenkins pipelines

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[uima-build-jenkins-shared-library] 01/01: [UIMA-6307] Centralize Jenkins pipelines

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/uima-build-jenkins-shared-library.git

commit b9ab65c476fd97b789d0e98dc23417fc61a81aa3
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Mon Jan 25 15:23:36 2021 +0100

    [UIMA-6307] Centralize Jenkins pipelines
    
    - Added initial shared pipeline
---
 .gitignore                      |   4 ++
 pom.xml                         |  46 ++++++++++++++
 vars/createConfiguration.groovy |  33 ++++++++++
 vars/defaultPipeline.groovy     | 134 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 217 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cd578f0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/target/
+.classpath
+.project
+.settings
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..3dc06e5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,46 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.uima</groupId>
+  <artifactId>uima-build-jenkins-shared-library</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+
+  <parent>
+    <artifactId>apache</artifactId>
+    <groupId>org.apache</groupId>
+    <version>23</version>
+    <relativePath />
+  </parent>
+  
+  <name>Apache UIMA - Jenkins Shared Library</name>
+  
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  
+  <build>
+    <sourceDirectory>${project.basedir}/src</sourceDirectory>
+    <testSourceDirectory>${project.basedir}/test</testSourceDirectory>
+  </build>
+</project>
\ No newline at end of file
diff --git a/vars/createConfiguration.groovy b/vars/createConfiguration.groovy
new file mode 100644
index 0000000..1ec756a
--- /dev/null
+++ b/vars/createConfiguration.groovy
@@ -0,0 +1,33 @@
+#!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.
+*/
+def call(body) {
+  def config = [
+    agentLabel: '',
+    maven: 'maven_latest',
+    jdk: 'jdk_1.8_latest',
+    extraMavenArguments: ''
+  ]
+  
+  body.resolveStrategy = Closure.DELEGATE_FIRST
+  body.delegate = config
+  body()
+  
+  return config
+}
diff --git a/vars/defaultPipeline.groovy b/vars/defaultPipeline.groovy
new file mode 100644
index 0000000..8407639
--- /dev/null
+++ b/vars/defaultPipeline.groovy
@@ -0,0 +1,134 @@
+#!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.
+*/
+def call(body) {
+  def config = createConfiguration(body)
+    
+  pipeline {
+    agent config.agentLabel
+  
+    tools {
+      maven config.maven
+      jdk config.jdk
+    }
+  
+    options {
+      buildDiscarder(logRotator(
+        numToKeepStr: '25',
+        artifactNumToKeepStr: '5'
+      ))
+      
+      // Seems not to be working reliably yet: https://issues.jenkins-ci.org/browse/JENKINS-48556
+      // timestamps()
+    }
+    
+    parameters {
+      string(
+        name: 'extraMavenArguments',
+        defaultValue: config.extraMavenArguments,
+        description: "Extra arguments to be passed to maven (for testing; overrides only current build)")
+    }
+  
+    stages {
+      // Display information about the build environemnt. This can be useful for debugging
+      // build issues.
+      stage("Build info") {
+        steps {
+          echo '=== Environment variables ==='
+          script {
+            if (isUnix()) {
+              sh 'printenv'
+            }
+            else {
+              bat 'set'
+            }
+          }
+        }
+      }
+          
+      // Perform a merge request build. This is a conditional stage executed with the GitLab
+      // sources plugin triggers a build for a merge request. To avoid conflicts with other
+      // builds, this stage should not deploy artifacts to the Maven repository server and
+      // also not install them locally.
+      stage("Pull request build") {
+        when { branch 'PR-*' }
+      
+        steps {
+          script {
+            currentBuild.description = 'Triggered by: <a href="' + CHANGE_URL + '">' + BRANCH_NAME +
+              ': ' + env.CHANGE_BRANCH + '</a> (' +  env.CHANGE_AUTHOR_DISPLAY_NAME + ')'
+          }
+  
+          withMaven(maven: config.maven, jdk: config.jdk) {
+            script {
+              def mavenCommand = 'mvn ' +
+                  config.extraMavenArguments +
+                  ' -U -Dmaven.test.failure.ignore=true clean verify';
+                  
+              if (isUnix()) {
+                sh script: mavenCommand
+              }
+              else {
+                bat script: mavenCommand
+              }
+            }
+          }
+          
+          script {
+            def mavenConsoleIssues = scanForIssues tool: mavenConsole()
+            def javaIssues = scanForIssues tool: java()
+            def javaDocIssues = scanForIssues tool: javaDoc()
+            publishIssues issues: [mavenConsoleIssues, javaIssues, javaDocIssues]
+          }
+        }
+      }
+      
+      // Perform a SNAPSHOT build of a main branch. This stage is typically executed after a
+      // merge request has been merged. On success, it deploys the generated artifacts to the
+      // Maven repository server.
+      stage("SNAPSHOT build") {
+        when { branch pattern: "main|main-v2", comparator: "REGEXP" }
+        
+        steps {
+          withMaven(maven: config.maven, jdk: config.jdk) {
+            script {
+              def mavenCommand = 'mvn ' +
+                config.extraMavenArguments +
+                ' -U -Dmaven.test.failure.ignore=true clean deploy'
+                
+              if (isUnix()) {
+                sh script: mavenCommand
+              }
+              else {
+                bat script: mavenCommand
+              }
+            }
+          }
+          
+          script {
+            def mavenConsoleIssues = scanForIssues tool: mavenConsole()
+            def javaIssues = scanForIssues tool: java()
+            def javaDocIssues = scanForIssues tool: javaDoc()
+            publishIssues issues: [mavenConsoleIssues, javaIssues, javaDocIssues]
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file