From: Martin Stockhammer Date: Thu, 25 Oct 2018 20:04:55 +0000 (+0200) Subject: Adding environment variable for user config file X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c069d160f92e67669150a376fec6661025b2d4b8;p=archiva.git Adding environment variable for user config file --- diff --git a/Jenkinsfile b/Jenkinsfile index 4a227c67c..cad0a0adb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,6 +33,7 @@ buildJdk9 = 'JDK 1.9 (latest)' buildJdk10 = 'JDK 10 (latest)' buildMvn = 'Maven 3.5.2' deploySettings = 'archiva-uid-jenkins' + INTEGRATION_PIPELINE = "Archiva-IntegrationTests-Gitbox" pipeline { @@ -40,9 +41,14 @@ pipeline { label "${LABEL}" } + + stages { stage('BuildAndDeploy') { + environment { + ARCHIVA_USER_CONFIG_FILE='/tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml' + } steps { timeout(120) { withMaven(maven: buildMvn, jdk: buildJdk, @@ -75,6 +81,7 @@ pipeline { } post { always { + sh "rm -f /tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml" junit testResults: '**/target/surefire-reports/TEST-*.xml' } success { @@ -95,6 +102,9 @@ pipeline { stage('JDKs') { parallel { stage('JDK9') { + environment { + ARCHIVA_USER_CONFIG_FILE='/tmp/archiva-master-jdk-9-${env.JOB_NAME}.xml' + } steps { ws("${env.JOB_NAME}-JDK9") { checkout scm @@ -114,8 +124,16 @@ pipeline { } } } + post { + always { + sh "rm -f /tmp/archiva-master-jdk-9-${env.JOB_NAME}.xml" + } + } } stage('JDK10') { + environment { + ARCHIVA_USER_CONFIG_FILE='/tmp/archiva-master-jdk-10-${env.JOB_NAME}.xml' + } steps { ws("${env.JOB_NAME}-JDK10") { checkout scm @@ -135,6 +153,11 @@ pipeline { } } } + post { + always { + sh "rm -f /tmp/archiva-master-jdk-10-${env.JOB_NAME}.xml" + } + } } } } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index a8dddadc5..cd1635d6b 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -22,6 +22,7 @@ package org.apache.archiva.configuration; import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; @@ -326,10 +327,20 @@ public class ArchivaConfigurationTest { DefaultArchivaConfiguration archivaConfiguration = (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "default" ); + String expectedFile = System.getProperty( "user.home" ) + "/.m2/archiva.xml"; + String systemFile = System.getProperty(ArchivaConfiguration.USER_CONFIG_PROPERTY); + if (StringUtils.isNotEmpty( systemFile )) { + expectedFile = systemFile; + } else + { + String envFile = System.getenv( ArchivaConfiguration.USER_CONFIG_ENVVAR ); + if ( StringUtils.isNotEmpty( envFile ) ) + expectedFile = envFile; + } archivaConfiguration.reload(); - assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml", + assertEquals( expectedFile, archivaConfiguration.getUserConfigFilename() ); assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml", archivaConfiguration.getAltConfigFilename() ); @@ -496,6 +507,8 @@ public class ArchivaConfigurationTest public void testLoadConfigurationFromInvalidBothLocationsOnDisk() throws Exception { + String propFile = System.getProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY ); + System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, "${basedir}/target/*intentionally:invalid*/.m2/archiva-user.xml" ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-both" ); Configuration config = archivaConfiguration.getConfiguration(); @@ -509,6 +522,10 @@ public class ArchivaConfigurationTest { /* expected exception */ } + if (propFile!=null) + { + System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, propFile ); + } } @Test diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 8fe71455f..9071317e9 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -77,16 +77,6 @@ - - - -