We have a Spring Boot application.
It has a source/resources/properties/application.properties file, which is a fallback/base properties for all environments.
It contains the line:
app.buildNumber=%BITBUCKET_BUILD_NUMBER%
I have a set-build-number.sh script which runs before the Maven build, and basically does this:
PROP_FILE=$BITBUCKET_CLONE_DIR/platform/src/main/resources/application.properties
echo "Setting build number to: $BITBUCKET_BUILD_NUMBER in properties file: $PROP_FILE"
sed -i".original" -e "s/%BITBUCKET_BUILD_NUMBER%/$BITBUCKET_BUILD_NUMBER/g" $PROP_FILE
grep "app.buildNumber" $PROP_FILE
And in the build logs, I see the following:
+ ./scripts/set-build-number.sh
Setting build number to: 3795 in properties file: /opt/atlassian/pipelines/agent/build/platform/src/main/resources/application.properties
app.buildNumber=3795
So, everything looks fine so far.
However, when I look at value returned by the application (via REST API), it is still set to the original placeholder value.
What am I doing wrong?
Thanks.
Hi Phillip,
Please see the property entry, bash script and output in my original post.
The following line is the output of the grep command above:
app.buildNumber=3795
So, the sed command is definitely working correctly.
My understanding was that the repo gets cloned (to a working directory), my property substitution would work off of that clone, and then the artifact gets built from that source and then deployed (we deploy to Heroku).
If it's the correct build number, then where does the number get read from?
When the app runs, the build number gets read by our Spring Boot application from the application.properties file.
Does it need to be committed back to the repository at any stage?
That's my question for you guys. Does it require a commit? Am I misunderstanding the build process? (i.e. that working directory gets used to build the final artifact)
Thanks,
Chris
My understanding was that the repo gets cloned (to a working directory), my property substitution would work off of that clone, and then the artifact gets built from that source and then deployed (we deploy to Heroku).
You've got the right assumption here.
That's my question for you guys. Does it require a commit? Am I misunderstanding the build process? (i.e. that working directory gets used to build the final artifact)
In this case it doesn't sound like you need a commit.
Everything seems fine in your Pipelines configuration, as far as I can tell.
Does this work correctly if you do the same thing locally? (You can try use Docker to debug if you need)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris,
Can you verify that the file has the build number correctly substituted with a cat command?
cat $PROP_FILE
Do you see if the placeholder value, or the desired build number?
If it's the placeholder then the substitution command will need updating.
If it's the correct build number, then where does the number get read from? Does it need to be committed back to the repository at any stage?
Thanks,
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.