Today I was attempting to change /target/bitbucket/home/logback.xml
to enable debugging and in the process observed some strange interaction between atlas-run
, bitbucket-maven-plugin
and /target/bitbucket/home
:
- Creating
/target/bitbucket/home/logback.xml
early in the build withmaven-resource-plugin
[1] results in all of the data in/target/bitbucket/home
being missing as expected - If I try to be sneaky and use
<phase>package</phase>
so that my file is copied after the homedir is created but before bitbucket is started, thenlogback.xml
is created but now I’m missing the test data and my plugin - there are a bunch of other files in/target/bitbucket/home
but I cannot see the demo repository [2] - Inside
/target/bitbucket/home/NOTE
, there is a message saying that the directory is based on the contents ofbitbucket-it-resources.zip
… I was able to get files into this zip file by dumping them into${project.build.directory}/bitbucket/tmp-resources/generated-resources/bitbucket-home
by changingoutputDirectory
. This worked for new files but not ones that I wanted to modify (eglogback.xmlx
can be updated butlogback.xml
always has the content from upstream (it must be written after the local files are gathered…) - I tried to modify the content of
bitbucket-it-resources.zip
after it was created but before bitbucket was started usingtruezip-maven-plugin
[3]: -
<phase>package</phase>
or<phase>test</phase>
results in a tinybitbucket-it-resources.zip
containing onlylogback.xml
(breaks plugin) -
<phase>pre-integration-test</phase>
does not appear to be executed as part ofatlas-run
- I was unable to identify a suitable phase to run the repacking at the right time, using
mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list
to work out timings - Searching for AMPS tickets, I found Atlassian Maven Plugin Suite - Issues - Ecosystem Jira which describes a very simple override procedure that negates the need for all of the above: create “override” files in
src/test/resources/bitbucket-home
and they will be copied into place.
My questions are:
- Why wasn’t I able to just copy a file into the homedir after it had been unpacked (2)? There were no visible errors, the process just seems to die somewhere. I feel like there is an execption being swallowed somewhere but nothing was jumping out at me in
AbstractProductHandler
. It would be nice to be able to just dump files into this directory and have them be used unless there is a reason why this can’t be? - (To satisify my curiosity) is there a phase/maven trick that would have let me alter the zip file at just the right point so that it could have an updated
logback.xml
- Is there anyone from Atlassian who can update the docs https://developer.atlassian.com/server/framework/atlassian-sdk/writing-your-first-plugin-faq/#using-your-own-log4j-configuration-for-your-plugin since Log4J doesn’t work with Bitbucket? I already added a note at Logging in a plugin for Bitbucket server?
- The override mechanism is useful but doesn’t seem to be documented anywhere… Am I missing something?
Thanks!
SDK info
ATLAS Version: 8.0.16
ATLAS Home: /usr/share/atlassian-plugin-sdk-8.0.16
ATLAS Scripts: /usr/share/atlassian-plugin-sdk-8.0.16/bin
ATLAS Maven Home: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4
AMPS Version: 8.0.2
--------
Executing: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4/bin/mvn --version -gs /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4/conf/settings.xml
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T04:33:14+10:00)
Maven home: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4
Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8.0_161/jre
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-25-generic", arch: "amd64", family: "unix"
[1] maven-resources-plugin
- copy a file
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>override-logback.xml</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/bitbucket/home</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>logback.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
[2] How to find the demo repository
find target -name 'repository-config'
[3] truezip-maven-plugin
- repack the zip
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>fix-crazy-logging</id>
<goals>
<goal>copy</goal>
</goals>
<phase>package</phase>
<configuration>
<files>
<file>
<source>${project.basedir}/logback.xml</source>
<outputDirectory>${project.build.directory}/bitbucket/bitbucket-it-resources.zip/generated-resources/bitbucket-home</outputDirectory>
</file>
</files>
</configuration>
</execution>
</executions>
</plugin>