Unverified Commit 67421db6 authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Merge pull request #333 from gradle/dd/build-scan-failure

Report failure to publish build scan in Job Summary
parents 2335d511 ce3874fe
Loading
Loading
Loading
Loading
+1
Changes for .github/workflow-samples/groovy-dsl/settings.gradle: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
plugins {
    id "com.gradle.enterprise" version "3.10.2"
    id "com.gradle.common-custom-user-data-gradle-plugin" version "1.7.2"
}

gradleEnterprise {
+1
Changes for .github/workflow-samples/kotlin-dsl/settings.gradle.kts: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
plugins {
    id("com.gradle.enterprise") version "3.10.2"
    id("com.gradle.common-custom-user-data-gradle-plugin") version "1.7.2"
}

gradleEnterprise {
+4 −1
Changes for .github/workflows/demo-job-summary.yml: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,7 +25,10 @@ jobs:
      run: ./gradlew assemble
    - name: Build kotlin-dsl project without build scan
      working-directory: .github/workflow-samples/kotlin-dsl
      run: ./gradlew check --no-scan
      run: ./gradlew assemble check --no-scan
    - name: Build kotlin-dsl project with build scan publish failure
      working-directory: .github/workflow-samples/kotlin-dsl
      run: ./gradlew check -Dgradle.enterprise.url=https://not.valid.server
    - name: Build groovy-dsl project
      working-directory: .github/workflow-samples/groovy-dsl
      run: ./gradlew assemble
+35 −20
Changes for dist/main/index.js: 35 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -66034,28 +66034,43 @@ function loadBuildResults() {
exports.loadBuildResults = loadBuildResults;
function writeSummaryTable(results) {
    core.summary.addHeading('Gradle Builds', 3);
    core.summary.addTable([
        [
            { data: 'Root Project', header: true },
            { data: 'Tasks', header: true },
            { data: 'Gradle Version', header: true },
            { data: 'Outcome', header: true }
        ],
        ...results.map(result => [
            result.rootProjectName,
            result.requestedTasks,
            result.gradleVersion,
            renderOutcome(result)
        ])
    ]);
    core.summary.addRaw('\n');
    core.summary.addRaw(`
<table>
    <tr>
        <th>Root Project</th>
        <th>Requested Tasks</th>
        <th>Gradle Version</th>
        <th>Build Outcome</th>
        <th>Build Scan™</th>
    </tr>${results.map(result => renderBuildResultRow(result)).join('')}
</table>
    `);
}
function renderBuildResultRow(result) {
    return `
    <tr>
        <td>${result.rootProjectName}</td>
        <td>${result.requestedTasks}</td>
        <td align='center'>${result.gradleVersion}</td>
        <td align='center'>${renderOutcome(result)}</td>
        <td>${renderBuildScan(result)}</td>
    </tr>`;
}
function renderOutcome(result) {
    const labelPart = result.buildScanUri ? 'Build%20Scan%E2%84%A2' : 'Build';
    const outcomePart = result.buildFailed ? 'FAILED-red' : 'SUCCESS-brightgreen';
    const badgeUrl = `https://img.shields.io/badge/${labelPart}-${outcomePart}?logo=Gradle`;
    const badgeHtml = `<img src="${badgeUrl}" alt="Gradle Build">`;
    const targetUrl = result.buildScanUri ? result.buildScanUri : '#';
    return result.buildFailed ? ':x:' : ':white_check_mark:';
}
function renderBuildScan(result) {
    if (result.buildScanFailed) {
        return renderBuildScanBadge('PUBLISH_FAILED', 'orange', 'https://docs.gradle.com/enterprise/gradle-plugin/#troubleshooting');
    }
    if (result.buildScanUri) {
        return renderBuildScanBadge('PUBLISHED', '06A0CE', result.buildScanUri);
    }
    return renderBuildScanBadge('NOT_PUBLISHED', 'lightgrey', 'https://scans.gradle.com');
}
function renderBuildScanBadge(outcomeText, outcomeColor, targetUrl) {
    const badgeUrl = `https://img.shields.io/badge/Build%20Scan%E2%84%A2-${outcomeText}-${outcomeColor}?logo=Gradle`;
    const badgeHtml = `<img src="${badgeUrl}" alt="Build Scan ${outcomeText}" />`;
    return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`;
}
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading