freeipa/ipatests/azure/templates/run-test.yml
Stanislav Levin b5bb436e9f Exit on fail in azure multiline script
By default, the `last` exit code returned from Azure script will be
checked and, if non-zero, treated as a step failure.  Luckily,
for Linux script is a shortcut for Bash. Hence errexit/e option
could be applied. But Azure pipelines doesn't set it by default:
https://github.com/microsoft/azure-pipelines-agent/issues/1803

For multiline script this is a problem, unless otherwise designed.
Some of benefits of checking the result of each subcommand:
- preventing subsequent issues (broken packages, container images, etc.)
- time saving (next steps will not run)
- good diagnostics (tells which part of script fails)

Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
2019-06-26 20:47:58 +03:00

30 lines
1.1 KiB
YAML

parameters:
imageName: 'freeipa-fedora-builder:latest'
containerName: 'container'
logsPath: 'logs'
taskToRun: 'run-tests'
testsToRun: ''
testsToIgnore: ''
steps:
- script: |
set -e
cnt=`docker create --hostname ipa.example.test --privileged -v $(Build.Repository.LocalPath):/freeipa -t ${{parameters.imageName}} /usr/sbin/init`
echo "##vso[task.setvariable variable=containerName;isOutput=true]$cnt"
name: createContainer
displayName: Create container for running a test
- script: |
set -e
docker start $(createContainer.containerName)
docker inspect $(createContainer.containerName)
displayName: Start container for running a test
- script: |
set -e
docker exec --env TESTS_TO_RUN="${{ parameters.testsToRun }}" \
--env TESTS_TO_IGNORE="${{ parameters.testsToIgnore }}" \
--env CI_RUNNER_LOGS_DIR="${{ parameters.logsPath }}" \
--privileged -t \
$(createContainer.containerName) \
/bin/bash --noprofile --norc -x /freeipa/ipatests/azure/azure-${{parameters.taskToRun}}.sh
displayName: Run test