Search code examples
springjenkinscloudbees

Spring PropertyPlaceholderConfigurer on Cloudbees cannot resolve property


My jenkins job copies the properties files (secret plugin) as follows

if [[ ! -d ~/.app ]]
then
mkdir ~/.app
fi
cp ${SECRET}/app.properties ~/.app/app.properties

This seems to work cos I do get

  • cp /scratch/jenkins/secrets/d97a8ac1-8edc-4b15-b328-dc777d1b13c9/app.properties /home/jenkins/.app/app.properties

And my deployed war has the following configuration

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="location" value="file:///home/jenkins/.app/app.properties"/>
</bean>

<bean id="facebookConfig" class="com.dk.integration.fb.service.FacebookConfig">
    <property name="applicationSecret" value="${app.secret}"></property>
    <property name="applicationKey" value="${app.key}"></property>
    <property name="applicationRedirectURI" value="${app.redirecturi}"></property>
</bean>

app.properties
app.secret=...
app.key=....
app.redirecturi=http://.....

However, I still get Could not resolve placeholder 'app.secret' at org.springframework.beans.factory.config.PlaceholderConfigurerSupport .doProcessProperties(PlaceholderConfigurerSupport.java:209)

I do not have multiple PropertyPlaceholderConfigurer's. Any help will be much appreciated.


Solution

  • DEV@Cloud build slaves and RUN@Cloud server nodes are distinct hosts. Your jenkins job can't be used to prepare runtime environment. To inject such configuration, use configuration parameters