You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2020/07/26 20:52:43 UTC
[logging-pipelines] branch master updated: Refactor complex stuff
into shared library
This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-pipelines.git
The following commit(s) were added to refs/heads/master by this push:
new 09febd1 Refactor complex stuff into shared library
09febd1 is described below
commit 09febd1220bf42955a9d08fbaa91076c4743f162
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sun Jul 26 15:52:23 2020 -0500
Refactor complex stuff into shared library
---
log4j/Jenkinsfile | 38 +++++++++----------------------
vars/cancelPreviousRunningBuilds.groovy | 25 +++++++++++++++++++++
vars/mvn.groovy | 40 +++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 28 deletions(-)
diff --git a/log4j/Jenkinsfile b/log4j/Jenkinsfile
index 967c37a..21420ba 100644
--- a/log4j/Jenkinsfile
+++ b/log4j/Jenkinsfile
@@ -46,16 +46,16 @@ pipeline {
environment {
LANG = 'C.UTF-8'
}
+ libraries {
+ // https://www.jenkins.io/doc/book/pipeline/shared-libraries/
+ // shared library reference to vars/
+ lib 'logging'
+ }
stages {
stage('Build') {
steps {
- // https://issues.jenkins-ci.org/browse/JENKINS-43353
- script {
- def buildNumber = BUILD_NUMBER as int
- if (buildNumber > 1) milestone(buildNumber - 1)
- milestone(buildNumber)
- }
- runMaven '-DskipTests clean install'
+ cancelPreviousRunningBuilds()
+ mvn '-DskipTests clean install'
}
}
stage('Test') {
@@ -63,7 +63,7 @@ pipeline {
parallel {
stage('Ubuntu') {
steps {
- runMaven '-Dmaven.test.failure.ignore=true verify'
+ mvn '-Dmaven.test.failure.ignore=true verify'
}
post {
always {
@@ -89,7 +89,7 @@ pipeline {
// note that previous test runs of log4j-mongodb* may have left behind an embedded mongo folder
// also note that we don't need to use the jenkins system property here as it's ubuntu-specific
bat 'if exist %userprofile%\\.embedmongo\\ rd /s /q %userprofile%\\.embedmongo'
- runMaven '-Dmaven.test.failure.ignore=true verify'
+ mvn '-Dmaven.test.failure.ignore=true verify'
}
post {
always {
@@ -109,7 +109,7 @@ pipeline {
}
}
steps {
- runMaven 'deploy'
+ mvn 'deploy'
}
}
}
@@ -128,21 +128,3 @@ pipeline {
}
}
}
-
-def runMaven(String args) {
- if (isUnix()) {
- configFileProvider([configFile(fileId: 'ubuntu', variable: 'TOOLCHAINS')]) {
- withEnv(['JAVA_HOME=/home/jenkins/tools/java/latest1.8']) {
- // note that the jenkins system property is set here to activate certain pom properties in
- // some log4j modules that compile against system jars (e.g., log4j-jmx-gui)
- sh "./mvnw --toolchains \"\$TOOLCHAINS\" -Djenkins ${args}"
- }
- }
- } else {
- configFileProvider([configFile(fileId: 'windows', variable: 'TOOLCHAINS')]) {
- withEnv(['JAVA_HOME=f:\\jenkins\\tools\\java\\latest1.8']) {
- bat ".\\mvnw.cmd --toolchains \"%TOOLCHAINS%\" ${args}"
- }
- }
- }
-}
diff --git a/vars/cancelPreviousRunningBuilds.groovy b/vars/cancelPreviousRunningBuilds.groovy
new file mode 100644
index 0000000..16f3dbe
--- /dev/null
+++ b/vars/cancelPreviousRunningBuilds.groovy
@@ -0,0 +1,25 @@
+/*
+ * 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
+ *
+ * https://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.
+ */
+
+// https://issues.jenkins-ci.org/browse/JENKINS-43353
+def call() {
+ def buildNumber = env.BUILD_NUMBER as int
+ if (buildNumber > 1) {
+ milestone(buildNumber - 1)
+ }
+ milestone(buildNumber)
+}
diff --git a/vars/mvn.groovy b/vars/mvn.groovy
new file mode 100644
index 0000000..bf15449
--- /dev/null
+++ b/vars/mvn.groovy
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ * https://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(String args) {
+ if (isUnix()) {
+ configFileProvider([configFile(fileId: 'ubuntu', variable: 'TOOLCHAINS')]) {
+ withEnv([
+ 'JAVA_HOME=/home/jenkins/tools/java/latest1.8',
+ 'PATH+MAVEN=/home/jenkins/tools/maven/latest3/bin:/home/jenkins/tools/java/latest1.8/bin'
+ ]) {
+ // note that the jenkins system property is set here to activate certain pom properties in
+ // some log4j modules that compile against system jars (e.g., log4j-jmx-gui)
+ sh "mvn --toolchains \"\$TOOLCHAINS\" -Djenkins ${args}"
+ }
+ }
+ } else {
+ configFileProvider([configFile(fileId: 'windows', variable: 'TOOLCHAINS')]) {
+ withEnv([
+ 'JAVA_HOME=f:\\jenkins\\tools\\java\\latest1.8',
+ 'PATH+MAVEN=f:\\jenkins\\tools\\maven\\latest3\\bin;f:\\jenkins\\tools\\java\\latest1.8\\bin'
+ ]) {
+ bat "mvn --toolchains \"%TOOLCHAINS%\" ${args}"
+ }
+ }
+ }
+}