Merge pull request #85 from gradle/dd/init-script

Use an init-script to capture buildScanPublished event
This commit is contained in:
Daz DeBoer authored and GitHub committed 2021-09-28 00:08:42 -06:00
commit 204870af89
7 files changed
+90 -20

No files matched your search

@@ -1,5 +1,5 @@
plugins {
id("com.gradle.enterprise") version("3.6.4")
id("com.gradle.enterprise") version("3.7")
}
gradleEnterprise {
@@ -1,3 +1,16 @@
plugins {
id("com.gradle.enterprise") version("3.7")
}
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishAlways()
uploadInBackground = false
}
}
rootProject.name = 'no-wrapper'
println "Using Gradle version: ${gradle.gradleVersion}"
+1 -1
View File
@@ -1,2 +1,2 @@
require('./sourcemap-register.js');module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return a(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return a(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return a(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return a(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirLine truncated
require('./sourcemap-register.js');module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return a(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return a(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return a(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return a(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirLine truncated
//# sourceMappingURL=index.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["/webpack/bootstrap","../node_modules/@actions/io/lib/io.js","../node_modules/@octokit/endpoint/node_modules/is-plain-object/dist/is-plain-object.js","../node_modules/@actions/exec/lib/toolrunner.js","../node_modules/wrappy/wrappy.js","../node_modules/@actions/cache/lib/internal/cacheUtils.js","../external \"tls\"","../(webpack)/ncc/@@notfound.js","../node_modules/xmlbuilder/lib/XMLDTDNotation.js","../node_modules/@opentelemetry/api/build/src/api/propagation.js","../node_modules/@azure/core-http/node_modules/uuid/dist/nil.js","../node_modules/@actions/tool-cache/lib/manifest.js","../node_modules/once/once.js","../node_modules/xmlbuilder/lib/DocumentPosition.js","../node_modules/@opentelemetry/api/build/src/trace/trace_state.js","../node_modules/@azure/core-asynciterator-polyfill/dist-esm/index.js","../node_modules/@actions/core/lib/utils.js","../node_modules/uuid/v1.js","../external \"os\"","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/permuteDomain.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v5.js","../node_modules/asynckit/serial.js","../node_modules/minimatch/minimatch.js","../node_modules/@opentelemetry/api/build/src/trace/link.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-pattern-helper.js","../node_modules/@actions/core/lib/file-command.js","../node_modules/@azure/core-http/node_modules/uuid/dist/version.js","../node_modules/@azure/abort-controller/dist/index.js","../node_modules/@actions/cache/lib/internal/cacheHttpClient.js","../node_modules/@opentelemetry/api/build/src/api/diag.js","../node_modules/@actions/github/lib/internal/utils.js","../external \"child_process\"","../src/main.ts","../node_modules/@opentelemetry/api/build/src/context/context.js","../node_modules/uuid/lib/rng.js","../node_modules/tunnel/lib/tunnel.js","../node_modules/@azure/core-tracing/node_modules/tslib/tslib.js","../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js","../node_modules/universalify/index.js","../node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js","../node_modules/delayed-stream/lib/delayed_stream.js","../node_modules/asynckit/lib/iterate.js","../node_modules/@opentelemetry/api/build/src/common/Time.js","../node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js","../src/execution.ts","../node_modules/@azure/core-http/node_modules/uuid/dist/v1.js","../node_modules/@actions/github/lib/context.js","../node_modules/@azure/core-http/node_modules/uuid/dist/parse.js","../node_modules/xml2js/lib/bom.js","../external \"https\"","../external \"timers\"","../node_modules/@opentelemetry/api/build/src/trace/SpanOptions.js","../node_modules/@actions/http-client/auth.js","../node_modules/@azure/core-auth/dist/index.js","../node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js","../node_modules/@azure/core-http/node_modules/uuid/dist/regex.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v35.js","../node_modules/@azure/core-http/node_modules/uuid/dist/md5.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-pattern.js","../node_modules/@actions/cache/lib/internal/downloadUtils.js","../node_modules/xmlbuilder/lib/XMLNode.js","../node_modules/@azure/logger/node_modules/tslib/tslib.js","../node_modules/@azure/core-tracing/dist/index.js","../node_modules/xmlbuilder/lib/XMLNodeList.js","../node_modules/semver/semver.js","../node_modules/@actions/glob/lib/glob.js","../src/provision.ts","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-glob-options-helper.js","../node_modules/@opentelemetry/api/build/src/common/Exception.js","../external \"buffer\"","../node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../node_modules/@actions/glob/lib/internal-globber.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v3.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/glob.js","../external \"string_decoder\"","../node_modules/brace-expansion/index.js","../node_modules/xmlbuilder/lib/index.js","../src/gradlew.ts","../node_modules/@actions/glob/lib/internal-match-kind.js","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/memstore.js","../node_modules/asynckit/index.js","../src/caches.ts","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/store.js","../node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js","../node_modules/xmlbuilder/lib/XMLStringWriter.js","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/pathMatch.js","../node_modules/xml2js/lib/processors.js","../external \"assert\"","../node_modules/before-after-hook/lib/register.js","../node_modules/@azure/storage-blob/dist/index.js","../node_modules/@actions/glob/lib/internal-path.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-search-state.js","../node_modules/@octokit/endpoint/dist-node/index.js","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/cookie.js","../Line truncated
{"version":3,"sources":["/webpack/bootstrap","../node_modules/@actions/io/lib/io.js","../node_modules/@octokit/endpoint/node_modules/is-plain-object/dist/is-plain-object.js","../node_modules/@actions/exec/lib/toolrunner.js","../node_modules/wrappy/wrappy.js","../node_modules/@actions/cache/lib/internal/cacheUtils.js","../external \"tls\"","../(webpack)/ncc/@@notfound.js","../node_modules/xmlbuilder/lib/XMLDTDNotation.js","../node_modules/@opentelemetry/api/build/src/api/propagation.js","../node_modules/@azure/core-http/node_modules/uuid/dist/nil.js","../node_modules/@actions/tool-cache/lib/manifest.js","../node_modules/once/once.js","../node_modules/xmlbuilder/lib/DocumentPosition.js","../node_modules/@opentelemetry/api/build/src/trace/trace_state.js","../node_modules/@azure/core-asynciterator-polyfill/dist-esm/index.js","../node_modules/@actions/core/lib/utils.js","../node_modules/uuid/v1.js","../external \"os\"","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/permuteDomain.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v5.js","../node_modules/asynckit/serial.js","../node_modules/minimatch/minimatch.js","../node_modules/@opentelemetry/api/build/src/trace/link.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-pattern-helper.js","../node_modules/@actions/core/lib/file-command.js","../node_modules/@azure/core-http/node_modules/uuid/dist/version.js","../node_modules/@azure/abort-controller/dist/index.js","../node_modules/@actions/cache/lib/internal/cacheHttpClient.js","../node_modules/@opentelemetry/api/build/src/api/diag.js","../node_modules/@actions/github/lib/internal/utils.js","../external \"child_process\"","../src/main.ts","../node_modules/@opentelemetry/api/build/src/context/context.js","../node_modules/uuid/lib/rng.js","../node_modules/tunnel/lib/tunnel.js","../node_modules/@azure/core-tracing/node_modules/tslib/tslib.js","../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js","../node_modules/universalify/index.js","../node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js","../node_modules/delayed-stream/lib/delayed_stream.js","../node_modules/asynckit/lib/iterate.js","../node_modules/@opentelemetry/api/build/src/common/Time.js","../src/build-scan-capture.ts","../node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js","../src/execution.ts","../node_modules/@azure/core-http/node_modules/uuid/dist/v1.js","../node_modules/@actions/github/lib/context.js","../node_modules/@azure/core-http/node_modules/uuid/dist/parse.js","../node_modules/xml2js/lib/bom.js","../external \"https\"","../external \"timers\"","../node_modules/@opentelemetry/api/build/src/trace/SpanOptions.js","../node_modules/@actions/http-client/auth.js","../node_modules/@azure/core-auth/dist/index.js","../node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js","../node_modules/@azure/core-http/node_modules/uuid/dist/regex.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v35.js","../node_modules/@azure/core-http/node_modules/uuid/dist/md5.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-pattern.js","../node_modules/@actions/cache/lib/internal/downloadUtils.js","../node_modules/xmlbuilder/lib/XMLNode.js","../node_modules/@azure/logger/node_modules/tslib/tslib.js","../node_modules/@azure/core-tracing/dist/index.js","../node_modules/xmlbuilder/lib/XMLNodeList.js","../node_modules/semver/semver.js","../node_modules/@actions/glob/lib/glob.js","../src/provision.ts","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-glob-options-helper.js","../node_modules/@opentelemetry/api/build/src/common/Exception.js","../external \"buffer\"","../node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../node_modules/@actions/glob/lib/internal-globber.js","../node_modules/@azure/core-http/node_modules/uuid/dist/v3.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/glob.js","../external \"string_decoder\"","../node_modules/brace-expansion/index.js","../node_modules/xmlbuilder/lib/index.js","../src/gradlew.ts","../node_modules/@actions/glob/lib/internal-match-kind.js","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/memstore.js","../node_modules/asynckit/index.js","../src/caches.ts","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/store.js","../node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js","../node_modules/xmlbuilder/lib/XMLStringWriter.js","../node_modules/@azure/core-http/node_modules/tough-cookie/lib/pathMatch.js","../node_modules/xml2js/lib/processors.js","../external \"assert\"","../node_modules/before-after-hook/lib/register.js","../node_modules/@azure/storage-blob/dist/index.js","../node_modules/@actions/glob/lib/internal-path.js","../node_modules/@actions/cache/node_modules/@actions/glob/lib/internal-search-state.js","../node_modules/@octokit/endpoint/dist-node/index.js","../node_modules/@azure/core-http/node_modules/tLine truncated
+52
View File
@@ -0,0 +1,52 @@
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
}
fs.writeFileSync(
initScript,
`
import org.gradle.util.GradleVersion
// Don't run against the included builds (if the main build has any).
def isTopLevelBuild = gradle.getParent() == null
if (isTopLevelBuild) {
def version = GradleVersion.current().baseVersion
def atLeastGradle5 = version >= GradleVersion.version("5.0")
def atLeastGradle6 = version >= GradleVersion.version("6.0")
if (atLeastGradle6) {
settingsEvaluated { settings ->
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
registerCallbacks(settings.extensions["gradleEnterprise"], settings.rootProject.name)
}
}
} else if (atLeastGradle5) {
projectsEvaluated { gradle ->
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
registerCallbacks(gradle.rootProject.extensions["gradleEnterprise"], gradle.rootProject.name)
}
}
}
}
def registerCallbacks(gradleEnterprise, rootProjectName) {
gradleEnterprise.with {
buildScan {
def scanFile = new File("gradle-build-scan.txt")
buildScanPublished { buildScan ->
scanFile.text = buildScan.buildScanUri
}
}
}
}
`
)
return initScript
}
+22 -15
View File
@@ -1,29 +1,36 @@
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,
argv: string[]
args: string[]
): Promise<BuildResult> {
let publishing = false
let buildScanUrl: string | undefined
const status: number = await exec.exec(executable, argv, {
// TODO: instead of running with no-daemon, run `--stop` in post action.
args.push('--no-daemon')
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)
}
const status: number = await exec.exec(executable, args, {
cwd: root,
ignoreReturnCode: true,
listeners: {
stdline: (line: string) => {
if (line.includes('Publishing build scan...')) {
publishing = true
}
if (publishing && line.startsWith('http')) {
buildScanUrl = line.trim()
publishing = false
}
}
}
ignoreReturnCode: true
})
if (fs.existsSync(buildScanFile)) {
buildScanUrl = fs.readFileSync(buildScanFile, 'utf-8')
}
return new BuildResultImpl(status, buildScanUrl)
}
-2
View File
@@ -16,8 +16,6 @@ export async function run(): Promise<void> {
await caches.restore(buildRootDirectory)
const args: string[] = parseCommandLineArguments()
// TODO: instead of running with no-daemon, run `--stop` in post action.
args.push('--no-daemon')
const result = await execution.execute(
await resolveGradleExecutable(