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.ymlin 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.shThe commands install XSpec in
/tmp/xspecand the Saxon processor in/tmp/xspec/saxonand set the path to the Saxon jar. The commands labelledscriptnavigate into thetestdirectory 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.shthat runs all the XSpec tests in thetestdirectory:#! /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 doneThis 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.shis 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:
