mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Persist build-scan-capture init script into Gradle User Home
Instead of writing this file to a temp directory and referencing it on the Gradle command line, the init script is now written to Gradle User Home so that it is picked up automatically.
This commit is contained in:
parent
b0c29bffb7
commit
a72af0b6a6
3 changed files with 6 additions and 15 deletions
|
@ -1,14 +1,6 @@
|
|||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import * as core from '@actions/core'
|
||||
|
||||
export function writeInitScript(): string {
|
||||
const tmpDir = process.env['RUNNER_TEMP'] || ''
|
||||
const initScript = path.resolve(tmpDir, 'build-scan-capture.init.gradle')
|
||||
core.info(`Writing init script: ${initScript}`)
|
||||
if (fs.existsSync(initScript)) {
|
||||
return initScript
|
||||
}
|
||||
export function writeBuildScanCaptureInitScript(initScript: string): void {
|
||||
fs.writeFileSync(
|
||||
initScript,
|
||||
`
|
||||
|
@ -46,5 +38,4 @@ def registerCallbacks(buildScanExtension, rootProjectName) {
|
|||
}
|
||||
`
|
||||
)
|
||||
return initScript
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import * as exec from '@actions/exec'
|
|||
|
||||
import {AbstractCache, CacheEntryListener, CacheListener} from './cache-base'
|
||||
import {getCacheKeyPrefix, hashFileNames, tryDelete} from './cache-utils'
|
||||
import {writeBuildScanCaptureInitScript} from './build-scan-capture'
|
||||
|
||||
const META_FILE_DIR = '.gradle-build-action'
|
||||
|
||||
|
@ -32,6 +33,10 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||
const propertiesFile = path.resolve(gradleUserHome, 'gradle.properties')
|
||||
this.debug(`Initializing gradle.properties to disable daemon: ${propertiesFile}`)
|
||||
fs.writeFileSync(propertiesFile, 'org.gradle.daemon=false')
|
||||
|
||||
const initScript = path.resolve(gradleUserHome, 'init.gradle')
|
||||
this.debug(`Adding init script to capture build scans: ${initScript}`)
|
||||
writeBuildScanCaptureInitScript(initScript)
|
||||
}
|
||||
|
||||
async afterRestore(listener: CacheListener): Promise<void> {
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
import * as exec from '@actions/exec'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import {writeInitScript} from './build-scan-capture'
|
||||
|
||||
export async function execute(executable: string, root: string, args: string[]): Promise<BuildResult> {
|
||||
let buildScanUrl: string | undefined
|
||||
|
||||
const initScript = writeInitScript()
|
||||
args.push('--init-script')
|
||||
args.push(initScript)
|
||||
|
||||
const buildScanFile = path.resolve(root, 'gradle-build-scan.txt')
|
||||
if (fs.existsSync(buildScanFile)) {
|
||||
fs.unlinkSync(buildScanFile)
|
||||
|
|
Loading…
Reference in a new issue