Azure PipelinesのWindows VM(vs-win2016),GradleでLaunchableにデータを送る。

公式ドキュメントに書いてある通りだけれど、実際に書いてみたのを残しておく。 docs.launchableinc.com

Javaだし、Windows独自の設定はPATHを通さないといけないくらいだった。

variables:
 LAUNCHABLE_TOKEN: 'v1:xxx/xxx:xxx'

pool:
  vmImage: 'vs2017-win2016'

steps:
- script: |
    python -m pip install --upgrade pip
    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    pip install --user --upgrade launchable~=1.0
    launchable verify || true
  displayName: 'Install dependencies'
- script: |
    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    launchable record build --name Build.BuildId --source src=.
  displayName: 'Sending build data to Launchable'
- task: Gradle@2
  inputs:
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.11'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'build jacocoTestReport'
  displayName: "Gradle build & Jacoco Test Report"
- script: |
    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    launchable record tests --build Build.BuildId gradle ./build/test-results/test/
  displayName: 'Sending data to Launchable'
- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo
    summaryFileLocation: build/reports/jacoco/test/jacocoTestReport.xml
    #pathToSources: # Optional
    reportDirectory: build/reports/jacoco/test/html # Optional
    #additionalCodeCoverageFiles: # Optional
    failIfCoverageEmpty: false # Optional

最初のscriptでlaunchableをインストールする。ちなみにlaunchableコマンド実行するにはPATHを通す必要がある。これはWindowsの制約かな。。もっとうまい方法があるかもしれないが。

    python -m pip install --upgrade pip
    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    pip install --user --upgrade launchable~=1.0
    launchable verify || true

そのあと、すぐにコードの差分を送る。

    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    launchable record build --name $(Build.BuildId) --source src=.

ビルドとテスト完了後に、Launchableにデータを送る。ここでもPATHを通しておく必要がある。

    set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Roaming\Python\Python37\Scripts
    launchable record tests --build $(Build.BuildId) gradle ./build/test-results/test/

結構データ送らないと使えないみたいで、まだここまで。