Integration with Bitbucket Pipelines - xspec/xspec GitHub Wiki
Bitbucket Pipelines is a built in CI system for Atlassian Bitbucket.
The following example illustrates how to run XSpec tests in a Pipelines build for a project hosted on Bitbucket.
-
Create the following
bitbucket-pipelines.yml
in the root of your repository:pipelines: default: - step: script: # Install XSpec - echo "Installing XSpec" - git clone -b master https://github.com/xspec/xspec.git /tmp/xspec # Install Saxon - echo "Installing Saxon" - mkdir -p /tmp/saxon - export SAXON_CP=/tmp/saxon/saxon9he.jar - wget -O "${SAXON_CP}" https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.9.1-7/Saxon-HE-9.9.1-7.jar # script - cd test - echo "execute XSpec unit tests" - ./run-xspec-tests.sh
The commands install XSpec in
/tmp/xspec
and the Saxon processor in/tmp/xspec/saxon
and set the path to the Saxon jar. The commands labelledscript
navigate into thetest
directory and run a shell script that executes all the XSpec test suite. Modify the test directory to the location where your XSpec tests are stored. -
Create the shell script
run-xspec-tests.sh
that runs all the XSpec tests in thetest
directory:#! /bin/bash for xspecfile in *.xspec; do if /tmp/xspec/bin/xspec.sh -e "${xspecfile}" &> result.log; then echo "OK: ${xspecfile}" else echo "FAILED: ${xspecfile}" echo "---------- result.log" cat result.log echo "----------" exit 1 fi done
This shell script outputs the name of the successful XSpec test executed. If an XSpec fails, the script stops, provides the name of the failing test and output the error message stored in the log file
result.log
.Note that this
run-xspec-tests.sh
is only for illustration purposes. It is very slow. For more serious purposes, consider using Ant. -
Push to your Bitbucket repository the following files:
bitbucket-pipelines.yml
: this must be pushed to the root of the repository you want to test. You can configure different branches to use different scripts.run-xspec-tests.sh
: ideally this should be pushed to the same directory where your XSpec tests are located.- your XSpec tests
Here is an output of a successful build with XSpec tests on Pipelines: