Confluence search plugin backend 
This plugin integrates Confluence documents to Backstage' search engine.
It is used in combination with its frontend counter-part.
Installation
Add the plugin to your backend app:
cd packages/backend && yarn add @k-phoen/backstage-plugin-confluence-backend
Configure the plugin in app-config.yaml
:
confluence:
wikiUrl: https://org-name.atlassian.net/wiki
spaces: [ENG]
auth:
username: ${CONFLUENCE_USERNAME}
password: ${CONFLUENCE_PASSWORD}
It is also possible to use a Resource
in the catalog to specify the spaces
to index.
The Resource
should like like this:
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: company-confluence-spaces
description: List of all company Confluence spaces to index
annotations:
atlassian.net/confluence-spaces: 'Eng, Sales, Marketing, BizDev'
spec:
type: confluence-spaces
owner: my-team
Enable Confluence documents indexing in the search engine:
import { ConfluenceCollatorFactory } from '@k-phoen/backstage-plugin-confluence-backend';
export default async function createPlugin({
logger,
permissions,
discovery,
config,
tokenManager,
}: PluginEnvironment) {
const searchEngine = await ElasticSearchSearchEngine.fromConfig({
logger,
config,
});
const indexBuilder = new IndexBuilder({ logger, searchEngine });
const halfHourSchedule = env.scheduler.createScheduledTaskRunner({
frequency: Duration.fromObject({ minutes: 30 }),
timeout: Duration.fromObject({ minutes: 15 }),
initialDelay: Duration.fromObject({ seconds: 3 }),
});
indexBuilder.addCollator({
schedule: halfHourSchedule,
factory: ConfluenceCollatorFactory.fromConfig(env.config, {
logger: env.logger,
}),
});
const { scheduler } = await indexBuilder.build();
setTimeout(() => scheduler.start(), 3000);
useHotCleanup(module, () => scheduler.stop());
return await createRouter({
engine: indexBuilder.getSearchEngine(),
types: indexBuilder.getDocumentTypes(),
permissions,
config,
logger,
});
}
If you have decided to use the Catalog (Resource
) to define the spaces to index then there is a small change to the
initialisation code:
...
indexBuilder.addCollator({
schedule: halfHourSchedule,
factory: ConfluenceCollatorFactory.fromConfig(env.config, {
logger: env.logger,
catalogClient: new CatalogClient({ discoveryApi: env.discovery }),
}),
});
...
This will ensure the Catalog Client is specified - and it can then get the Resources
of the specified type.
License
This library is under the MIT license.