Test a Confluence instance for macro errors with GINT configuration

This article provides detailed steps to test a Confluence instance for macro errors with GINT configuration in a Mac machine.


  1. Create an SDE working folder. It is recommended that you create a working folder in your home folder and name it "sde":

    $ cd ~
    $ mkdir -p sde
  2. Install and configure the Atlassian SDK with homebrew:

    brew tap atlassian/tap
    brew install atlassian/tap/atlassian-plugin-sdk
  3. Configure the below environment variables in bash_profile:

    export SDE_HOME=$HOME/sde
    export ATLAS_HOME=/usr/share/atlassian-plugin-sdk-8.0.16
    export GROOVY_HOME=/root/sde/groovy-2.4.8
    export GANT_HOME=/root/sde/gant-1.10.0
    export JAVA_HOME=/root/java
  4. Download groovy 2.4.8 from apache-groovy-binary-2.4.8.zip:

    $cd ~/sde
    $wget https://bintray.com/artifact/download/groovy/maven/apache-groovy-binary-2.4.8.zip
    $unzip apache-groovy-binary-2.4.8.zip
  5. Download the GANT named 1.10.0 Binary compiled for use with Groovy 2.4.8 installation from Prepackaged Distributions Source and General Precompiled Distribution:

    $cd ~/sde
    $wget https://gant.github.io/distributions/gant-1.10.0-_groovy-2.4.8.tgz
    $tar -xvzf gant-1.10.0-_groovy-2.4.8.tgz
  6. Copy the gant-starter.conf file to /groovy-2.4.8/conf :

    $cp ~/sde/gant-1.10.0/conf/gant-starter.conf ~/sde/groovy-2.4.8/conf
  7. Download gint-2.8.0.jar from Downloads:

    $cd ~/sde
    $wget https://bitbucket.org/bob_swift/gint/downloads/gint-2.8.0.jar
  8. Run the below-mentioned command with gint-2.8.0.jar file:

    $atlas-mvn install:install-file -Dfile=~/sde//gint-2.8.0.jar -DgroupId=org.swift.tools -DartifactId=gint -Dversion=2.8.0 -Dpackaging=jar
  9. Create a file named as macroError.gant with the below script:

     * Copyright (c) 2009, 2011 Bob Swift
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *     http://www.apache.org/licenses/LICENSE-2.0
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * Created on Oct 20, 2011 by Bob Swift
     * This is a GINT test (https://studio.plugins.atlassian.com/wiki/display/GINT)
     * Test all pages within a Confluence space to see if specific text appears on the rendered page.
     * A specific use case is to look for macro errors on a page.
     * Run with something like:
     *     gant -f macroError.gant -Dverbose -Dspace=myspacekey -Ddatabase=confluence-3.5.13 -Dcli="/sde/atlassian-cli-2.2.0/atlassian confluence-3.5.13"
     * -Dspace - space key or space key like clause, % for all (not recommended as it will take a very long time!)
     * -Ddatabase - name of your Confluence database
     * -DdatabaseHost - host for your database if not the default localhost
     * -DdatabaseType - database type if not the default postgresql (mysql, mssql, oracle, db2)
     * -DdatabaseUser - user name to access the database, default automation
     * -DdatabasePassword - password, default automation
     * -Dcli - Confluence CLI used to access your Confluence instance remote API
    @Grab(group='org.swift.tools', module='gint', version='2.6.0-SNAPSHOT')
    import org.swift.tools.*
    includeTool << GintForConfluence
    includeTool << Helper
    includeTool << SqlHelper
    gint.initialize(this) // required
    failData = ['Unknown macro:', '<span class="error">'] // this is text that will flag a page as being in error
    space = helper.getRequiredParameterValue('space').toUpperCase()
    databaseConfig = [
        database: helper.getParameterValue('database', 'confluence'),
        host:     helper.getParameterValue('databaseHost', 'localhost'),
        type:     helper.getParameterValue('databaseType', 'postgresql'),
        user:     helper.getParameterValue('databaseUser', 'automation'),
        password: helper.getParameterValue('databasePassword', 'automation'),
    def sql = """
            'renderPage' as action,
            s.spaceKey || ':' || c.title as name,
            s.spaceKey as space,
            c.title as title,
            true as file,
            '[failData: failData]' as output_code
            content as c, spaces as s
            s.spaceid = c.spaceid
            and c.content_status = 'current'
            and c.contentid is not null
            and c.spaceid is not null
            and c.title <> ''
            and upper(s.spaceKey) like '${space}'
    helper.logWithFormat('sql', sql)
    connection = sqlHelper.getConnection(databaseConfig)
    gint.add(connection, sql)
    gint.finalizeTest() // final preparations for running tests
  10. Run the below command with Confluence CLI jar file location and Confluence database details in the terminal or command line.

    gant-1.10.0/bin/gant --classpath gint-2.8.0.jar -f macroError.gant -Dverbose -Dcli="java -jar /home/ubuntu/sde/atlassian-cli-8.8.0/lib/confluence-cli-8.8.0.jar --server confluence_url --user confluence_username --password confluence_password" -Dspace="zconfluencecli" -Ddatabase="test123" -DdatabaseHost="post.clclwjb9vztp.ap-south-1.rds.amazonaws.com" -DdatabaseType="Database_Type" -DdatabaseUser="Database_Username" -DdatabasePassword="Database_Password"

    This provides a list of unknown macros that are present in Confluence pages.