44import org .gradle .api .Project ;
55import org .jfrog .build .extractor .ci .BuildInfoFields ;
66import org .jfrog .build .extractor .ci .BuildInfoProperties ;
7+ import org .jfrog .build .extractor .ci .BuildInfoConfigProperties ;
8+ import org .apache .commons .lang3 .StringUtils ;
79import org .jfrog .build .api .util .CommonUtils ;
810import org .jfrog .build .extractor .BuildInfoExtractorUtils ;
911import org .jfrog .build .extractor .clientConfiguration .ArtifactoryClientConfiguration ;
1012
13+ import java .io .File ;
14+ import java .io .FileInputStream ;
15+ import java .io .InputStream ;
1116import java .util .Map ;
1217import java .util .Properties ;
1318import java .util .Set ;
@@ -46,6 +51,25 @@ public static void update(ArtifactoryClientConfiguration config, Project project
4651
4752 // Then System properties
4853 Properties mergedProps = BuildInfoExtractorUtils .mergePropertiesWithSystemAndPropertyFile (props , config .info .getLog ());
54+
55+ // Override file loading with explicit system property check to avoid Gradle daemon caching issues.
56+ String buildInfoPropFile = System .getProperty (BuildInfoConfigProperties .PROP_PROPS_FILE );
57+ String propSource = "system property (" + BuildInfoConfigProperties .PROP_PROPS_FILE + ")" ;
58+
59+ if (StringUtils .isBlank (buildInfoPropFile )) {
60+ buildInfoPropFile = System .getProperty (BuildInfoConfigProperties .ENV_BUILDINFO_PROPFILE );
61+ propSource = "system property (" + BuildInfoConfigProperties .ENV_BUILDINFO_PROPFILE + ")" ;
62+ }
63+
64+ // If we found a system property-based file path, reload it to ensure it takes priority over env var
65+ if (StringUtils .isNotBlank (buildInfoPropFile )) {
66+ Properties fileProps = loadBuildInfoProperties (buildInfoPropFile , config .info .getLog ());
67+ if (fileProps != null ) {
68+ mergedProps .putAll (fileProps );
69+ config .info .getLog ().debug ("Overriding with properties from " + propSource + ": " + buildInfoPropFile );
70+ }
71+ }
72+
4973 // Then special buildInfo properties
5074 Properties buildInfoProperties =
5175 BuildInfoExtractorUtils .filterDynamicProperties (mergedProps , BUILD_INFO_PROP_PREDICATE );
@@ -65,6 +89,29 @@ public static void update(ArtifactoryClientConfiguration config, Project project
6589 addDefaultPublisherAttributes (config , project .getRootProject ().getName (), "Gradle" , project .getGradle ().getGradleVersion ());
6690 }
6791
92+ /**
93+ * Helper method to load build info properties from a file with proper error handling
94+ */
95+ private static Properties loadBuildInfoProperties (String filePath , org .jfrog .build .api .util .Log log ) {
96+ if (StringUtils .isBlank (filePath )) {
97+ return null ;
98+ }
99+
100+ File propertiesFile = new File (filePath );
101+ if (!propertiesFile .exists ()) {
102+ log .warn ("Properties file not found at: " + filePath );
103+ return null ;
104+ }
105+
106+ try (InputStream inputStream = new FileInputStream (propertiesFile )) {
107+ Properties fileProps = new Properties ();
108+ fileProps .load (inputStream );
109+ return fileProps ;
110+ } catch (Exception e ) {
111+ log .error ("Failed to load properties from: " + filePath + " - " + e .getMessage ());
112+ return null ;
113+ }
114+ }
68115
69116 private static void fillProperties (Project project , Properties props ) {
70117 Project parent = project .getParent ();
0 commit comments