0

I have a groovy script that sends Mattermost messages to one of our MM Channels after a Jenkins run has completed with an error. It’s setup like this and works fine atm:

             pipelineContext.mattermostSend (
                channel: '#my-channel',
                endpoint: "<MM webhook URL>",
                text: "Build Failure: ${pipelineContext.env.JOB_NAME} ${pipelineContext.env.BUILD_NUMBER} (<${pipelineContext.env.BUILD_URL}|Open>)",
                message: "Build Failure: ${pipelineContext.env.JOB_NAME} ${pipelineContext.env.BUILD_NUMBER} (<${pipelineContext.env.BUILD_URL}|Open>)"
            )

Recently, it was decided that the endpoint should be in the Jenkins credentials configuration for the project as a Secret Text. I’ve set the matterMost send to now be the following:

            final String CREDENTIAL_ID = 'mm-credential'
            
            pipelineContext.withCredentials([pipelineContext.string(credentialsId: 'CREDENTIAL_ID', variable: 'CREDENTIAL')]) {
                pipelineContext.mattermostSend (
                    channel: '#my-channel',
                    endpoint: "$CREDENTIAL",
                    text: "Build Failure: ${pipelineContext.env.JOB_NAME} ${pipelineContext.env.BUILD_NUMBER} (<${pipelineContext.env.BUILD_URL}|Open>)",
                    message: "Build Failure: ${pipelineContext.env.JOB_NAME} ${pipelineContext.env.BUILD_NUMBER} (<${pipelineContext.env.BUILD_URL}|Open>)"
                )
            }

However I keep getting errors now when I try to pass in the new credential to the message: Mattermost Send Pipeline step configured values from global config - connector: false, icon: true, channel: false, color: trueERROR: Mattermost notification failed. See Jenkins logs for details.

I’ve tried tinkering with how to pass in the CREDENTIAL value for awhile but can’t seem to get a working MatterMost call to go through. Unfortunately I don’t have access to the jenkins logs atm so I wanted to see if anyone had any ideas what could be the problem?

I tried to change the endpoint value along with the quotes on it and trying to use a local variable. I still get an error.

vap
  • 31
  • 3

0 Answers0