This repository has been archived by the owner on Jun 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration - added `confluenceCreateSubpages` parameter to be able to switch off creation of subpages - changed `input` parameter into a list of files - one can now also configure a parent page by file asciidoc2confluence - added `scriptBasePath` variable which now MUST be set (couldn't find a better way to get the path to the Config.groovy file. Suggestions welcome!) - adopted new config parameters - added more log output - added check whether 'ancestorId' is provided, if not a new master page will be created README - switched from Markdown to Asciidoc - added section about usage with Maven and GMavenPlus
- Loading branch information
1 parent
659f307
commit b9114ac
Showing
4 changed files
with
180 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
|
||
// the asciidoc generated html file to be exported | ||
input = "asciidocOutput.html" | ||
// 'input' is an array of files to upload to Confluence with the ability | ||
// to configure a different parent page for each file. | ||
// | ||
// Attributes | ||
// - 'file': absolute or relative path to the asciidoc generated html file to be exported | ||
// - 'ancestorId': the id of the parent page in Confluence; leave this empty if a new parent shall be created in the space | ||
input = [ | ||
[ file: "asciidocOutput1.html", ancestorId: '' ], | ||
[ file: "asciidocOutput2.html", ancestorId: 123456 ] | ||
] | ||
|
||
// endpoint of the confluenceAPI (REST) to be used | ||
confluenceAPI = 'https://[yourServer]/[context]/rest/api/' | ||
confluenceAPI = 'https://[yourServer]/[context]/rest/api/' | ||
|
||
// the key of the confluence space to write to | ||
confluenceSpaceKey = 'asciidoc' | ||
confluenceSpaceKey = 'asciidoc' | ||
|
||
// variable to determine whether ".sect2" sections shall be split from the current page into subpages | ||
confluenceCreateSubpages = false | ||
|
||
// the pagePrefix will be a prefix for each page title | ||
// use this if you only have access to one confluence space but need to store several | ||
// pages with the same title - a different pagePrefix will make them unique | ||
confluencePagePrefix = '' | ||
confluencePagePrefix = '' | ||
|
||
// username:password of an account which has the right permissions to create and edit | ||
// confluence pages in the given space. | ||
// if you want to store it securely, fetch it from some external storage. | ||
// you might even want to prompt the user for the password | ||
confluenceCredentials = 'user:password'.bytes.encodeBase64().toString() | ||
confluenceCredentials = 'user:password'.bytes.encodeBase64().toString() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
= asciidoc2confluence | ||
:toc: | ||
:includedir: ./ | ||
:source-highlighter: coderay | ||
|
||
This is a groovy script to import HTML files generated by http://asciidoctor.org/[asciidoctor] to one or multiple https://www.atlassian.com/software/confluence/[Confluence] pages. | ||
|
||
The easiest way to get this up and running is to modify the `Config.groovy` to fit your environment and load the main script into the groovyConsole. You then need some HTML output from http://asciidoctor.org/[asciidoctor] (The https://raw.githubusercontent.com/arc42/arc42.github.io/master/template/en/arc42-template.html[arc42 template] might be a good starting point). Please note that the script is completely focussed on Asciidoctor output as it makes assumptions about the HTML structure (e.g. "sect1" and "sect2" css classes being present). | ||
|
||
When you start the script the first time, it will try to split the html file into subsections and push them to your confluence instance. This is done to be able to handle large documentation pages and to be able to send update notifications for specific sections of a large document. This can be switched off though by the `confluenceCreateSubpages` configuration parameter. | ||
|
||
|
||
== Configuration | ||
|
||
[source,groovy] | ||
.Config.groovy | ||
---- | ||
include::Config.groovy[] | ||
---- | ||
|
||
== Running the script | ||
|
||
The script can be run directly, via Maven or Gradle. It requires Java >= 7 and the `scriptBasePath` variable being set which points to the folder where to find the `Config.groovy` file. | ||
|
||
=== Usage with Maven | ||
|
||
The following `pom.xml` sample shows how to use the `asciidoc2confluence.groovy` script with your Maven build. It will run when you execute the `mvn gplus:execute` goal. | ||
|
||
[source,xml,linenums] | ||
---- | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.github.rdmueller</groupId> | ||
<artifactId>asciidoc2confluence</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>asciidoc2confluence sample</name> | ||
<description>An asciidoc2confluence sample pom.xml</description> | ||
<properties> | ||
<!-- The following class will be used in the MANIFEST.MF --> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<java.target.version>1.8</java.target.version> | ||
<java.source.version>1.8</java.source.version> | ||
</properties> | ||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<target>${java.target.version}</target> | ||
<source>${java.source.version}</source> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
<version>1.5</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>execute</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<properties> | ||
<property> | ||
<name>scriptBasePath</name> | ||
<value>${project.basedir}/src/main/groovy/</value> | ||
</property> | ||
</properties> | ||
<scripts> | ||
<script>file:///${project.basedir}/src/main/groovy/asciidoc2confluence.groovy</script> | ||
</scripts> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy-all</artifactId> | ||
<!-- any version of Groovy \>= 1.5.0 should work here --> | ||
<version>2.4.3</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
---- | ||
|
||
=== Usage with Gradle | ||
|
||
_to be done..._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters