Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Report back build URL immediately with Jeninksfile/pipelines #330

Open
altendky opened this issue Jun 7, 2019 · 1 comment
Open

Report back build URL immediately with Jeninksfile/pipelines #330

altendky opened this issue Jun 7, 2019 · 1 comment

Comments

@altendky
Copy link

altendky commented Jun 7, 2019

It would be nice to immediately report back the build URL instead of waiting until the build is done. I am using a pipeline so I would guess I would have to add a step other than the existing PhabricatorNotifier at the point in the build where I want the URL reported.

This looks to be implemented for non-pipelines.

#133
ChaitanyaPramod@cd3a3cb

@timbrown5
Copy link

timbrown5 commented Sep 6, 2019

Hey,
Not sure how helpful it is but I've been hitting my head against this today and came up with this scripted pipeline code (which needs the HTTPRequest plugin):

node() {
    stage("Report build to Phabricator") {
        // Report to Phabricator if this is a diff build
        if (params.DIFF_ID && params.DIFF_REPO && params.PHID ) {
            try{
                withCredentials([string(credentialsId: 'phab_arc_token', variable: 'ARC_TOKEN')]) {
                    def request_body = "api.token=${ARC_TOKEN}&buildTargetPHID=${params.PHID}&artifactKey=jenkins.uri&artifactType=uri&artifactData[uri]=${BUILD_URL}&artifactData[name]=%5B${JOB_NAME}%20%28Jenins%29%5D&artifactData[ui.external]=1"
                    httpRequest consoleLogResponseBody: true,
                        customHeaders: [[maskValue: false, name: 'Content-Type', value: 'application/x-www-form-urlencoded']],
                        httpMode: 'POST', ignoreSslErrors: true, requestBody: request_body, responseHandle: 'NONE', 
                        url: "${PHABRICATOR_URL}/api/harbormaster.createartifact",
                        validResponseContent: '"error_code":null'
                }
            } catch (err) {
                // Set build result to failure and report to Phabricator
                currentBuild.result = 'FAILURE'
                step([$class: 'PhabricatorNotifier', commentFile: '.phabricator-comment', commentOnSuccess: true,
                      commentSize: '1000', commentWithConsoleLinkOnFailure: true, coverageCheck: false,
                      coverageReportPattern: '**/coverage*.xml, **/cobertura*.xml, **/jacoco*.xml', 
                      coverageThreshold: 0.0, customComment: false, lintFile: '.phabricator-lint', lintFileSize: '100000', 
                      minCoverageThreshold: 100.0, preserveFormatting: false, processLint: false, uberallsEnabled: false])
                throw err
            }
        }
    }
}

For me this reports the build back to buildbot before it starts running on the node to do the job (it is running the HTTPRequest step on the master).
If you need a declarative pipeline version I can try re-writing it for that (but I'm not as familiar with it :).
Hope it helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants