Skip to content
This repository has been archived by the owner on Nov 17, 2018. It is now read-only.

Default non Jenkisfile webhook Look in a jenkinsfile project? #23

Open
kingdevnl opened this issue Jun 18, 2018 · 3 comments
Open

Default non Jenkisfile webhook Look in a jenkinsfile project? #23

kingdevnl opened this issue Jun 18, 2018 · 3 comments

Comments

@kingdevnl
Copy link

How could i make the embed in a Jenkinsfile pipeline build Look the same as a default embed from a freestyle build?

@jupjohn
Copy link
Collaborator

jupjohn commented Aug 14, 2018

I don't use pipelines myself so I think you're gonna have to play around and come back to me on that one. I'm sure there are variables exposed to the pipeline steps that you could access and use.

@jupjohn
Copy link
Collaborator

jupjohn commented Nov 7, 2018

@KocproZ bump

@KocproZ
Copy link
Owner

KocproZ commented Nov 7, 2018

I don`t know (yet) if it is doable in plugin itself, but I can give you a snippet that I created for other project:

        def artifactUrl = env.BUILD_URL + "artifact/"
        def msg = "**Status:** " + currentBuild.currentResult.toLowerCase() + "\n"
        msg += "**Branch:** ${BRANCH_NAME}\n"
        msg += "**Changes:** \n"
        if (!currentBuild.changeSets.isEmpty()) {
            currentBuild.changeSets.first().getLogs().each {
                msg += "- `" + it.getCommitId().substring(0, 8) + "` *" + it.getComment().substring(0, it.getComment().length()-1) + "*\n"
            }
        } else {
            msg += "no changes for this run\n"
        }

        if (msg.length() > 1024) msg.take(msg.length() - 1024)

        def filename
        msg += "\n **Artifacts:**\n"
        currentBuild.rawBuild.getArtifacts().each {
            filename = it.getFileName()
            msg += "- [${filename}](${artifactUrl}${it.getFileName()})\n"
        }

        withCredentials([string(credentialsId: 'discord_webhook', variable: 'discordWebhook')]) {
            discordSend thumbnail: "https://static.kocproz.ovh/warp-logo.png", successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), description: "${msg}", link: env.BUILD_URL, title: "Warp_Engine:${branch} #${BUILD_NUMBER}", webhookURL: "${discordWebhook}"
        }

It produces this:
image

Just modify some fields and you're good to go.

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

3 participants