Skip to content

Commit

Permalink
Fix: [AzurePipelines] Run commit checker only for PRs and pass it the…
Browse files Browse the repository at this point in the history
… target branch (#7356)
  • Loading branch information
glx22 authored and LordAro committed Mar 10, 2019
1 parent 9cb84a1 commit a1d028e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion azure-pipelines/templates/ci-git-rebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ steps:
git config user.email 'info@openttd.org'
git config user.name 'OpenTTD CI'
git rebase origin/${SYSTEM_PULLREQUEST_TARGETBRANCH}
displayName: 'Rebase to $(System.PullRequest.TargetBranch)'
displayName: 'Rebase to target branch'
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
18 changes: 18 additions & 0 deletions azure-pipelines/templates/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ parameters:
ContainerCommand: ''

steps:
# 'envVars' in the 'Docker@1' task is a bit funky. When you want to use a
# variable, you have to quote it. But the quote is also sent directly to
# Docker and ends up in the variable, which you don't want. To work around
# this, we set the correct variable first (which becomes an env-variable), and
# pass that env-variable through to Docker. We cannot use the normal
# 'variables' entry, as we are a template. So that results in this bit of
# Bash code. Not because it is pretty, but it is the only way we found that
# works.
- bash: |
echo "##vso[task.setvariable variable=TARGET_BRANCH]${SYSTEM_PULLREQUEST_TARGETBRANCH}"
echo "Target branch is ${SYSTEM_PULLREQUEST_TARGETBRANCH}"
displayName: "Set target branch"
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))

- task: Docker@1
${{ if eq(parameters.Image, 'compile-farm') }}:
displayName: 'Build'
${{ if eq(parameters.Image, 'compile-farm-ci') }}:
displayName: 'Build and test'
${{ if eq(parameters.Tag, 'commit-checker') }}:
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
inputs:
command: 'Run an image'
imageName: openttd/${{ parameters.Image }}:${{ parameters.Tag }}
volumes: '$(Build.SourcesDirectory):$(Build.SourcesDirectory)'
workingDirectory: '$(Build.SourcesDirectory)'
containerCommand: ${{ parameters.ContainerCommand }}
runInBackground: false
envVars: |
TARGET_BRANCH

0 comments on commit a1d028e

Please sign in to comment.