]> source.dussan.org Git - archiva.git/commitdiff
Adding environment variable for user config file
authorMartin Stockhammer <martin_s@apache.org>
Thu, 25 Oct 2018 20:04:55 +0000 (22:04 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Thu, 25 Oct 2018 20:04:55 +0000 (22:04 +0200)
Jenkinsfile
archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml

index 4a227c67c80fb9e8125d70d70bb71556417b1784..cad0a0adb420f94b489868aad044fe7ccbb77840 100644 (file)
@@ -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"
+                        }
+                    }
                 }
             }
         }
index a8dddadc523af3c78c0eacf2abbbcc933f1ee9f0..cd1635d6b8ce5ce33f699132a8a91d0ae7d207ec 100644 (file)
@@ -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
index 8fe71455f3f411bacda8976f355059c22e6fb108..9071317e90cc4664d26b45b13557c33800a49c8f 100644 (file)
         <configuration>
           <system/>
           <jndi prefix="java:comp/env" config-optional="true"/>
-          <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true"
-               config-name="org.apache.archiva.user"
-               config-at="org.apache.archiva"/>
-          <xml fileName="${user.home}/.m2/shared.xml" config-optional="true"
-               config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app"
-               config-forceCreate="true"/>
-          <properties fileName="${user.home}/.m2/security.properties" config-optional="true"
-                      config-at="org.apache.archiva.redback"/>
-          <properties fileName="${user.home}/.m2/archiva.properties" config-optional="true"
-                      config-at="org.apache.archiva.redback"/>
           <xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true"
                config-name="org.apache.archiva.base"
                config-at="org.apache.archiva"/>