Communication with giblab doesn't work when I use a shared library

Hello,

I have Jenkins for CI/CD and gitlab for code repo (both self hosted).

I’m using the gitlab plugin to update the pipeline status in gitlab. I’m also using web hooks.

I’ve created a shared library and confirmed that the CI/CD is working properly. However, it no longer updates the gitlab status.

For example, using the following script, everything works as expected. If I add “@Library(‘jenkins-shared-library’) _” at the beginning of the file (or make the library load implicitly), it won’t update anything over gitlab.

pipeline {
    agent any

    options {
        gitLabConnection('gitlab-connection')
        gitlabBuilds(builds: ['api-checkout'])
    }

    stages {
        stage('Checkout') {
            steps {
                updateGitlabCommitStatus name: 'api-checkout', state: 'running'
                checkout scm
            }
            post {
                success {
                    updateGitlabCommitStatus name: 'api-checkout', state: 'success'
                }
                failure {
                    updateGitlabCommitStatus name: 'api-checkout', state: 'failed'
                }
            }
        }
    }
    post {
        success {
            echo "✅ Successfully built and deployed"
        }
        failure {
            echo "❌ Build and deployment of failed"
        }
        always {
            echo "🧹 Cleaning up..."
            cleanWs()
        }
    }
}