gitlabCommitStatus unable to update status of pipeline

Hey folks, I have setup a jenkins pipeline to run on gitlab MRs. The pipeline gets triggered successfully with the webhook setup. And the pipeline is able to comment back on the MR with the build status. Now I am trying to send back the pipeline status to gitlab so that MR can be blocked on pipeline status. I don’t see the pipeline in gitlab under Source=External. I am suspecting the way I checkout the code in the pipeline is the issue. While browsing through the logs for gitlab plugin I saw the error:

Jul 11, 2023 5:25:23 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder
Call GitLab:
HTTP method: GET
URL: https://gitlab.my-org.com/api/v4/projects/90971/repository/commits/3ebaf5cdb93ee18913642e9155a66467a89cb7cf
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]
Jul 11, 2023 5:25:24 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder
Got response from GitLab:
URL: https://gitlab.my-org.com/api/v4/projects/90971/repository/commits/3ebaf5cdb93ee18913642e9155a66467a89cb7cf
Status: 404 Not Found
Response headers: [
Cache-Control = [no-cache],
Connection = [keep-alive],
Content-Length = [35],
Content-Type = [application/json],
Date = [Tue, 11 Jul 2023 05:25:24 GMT],
Server = [nginx],
Vary = [Origin],
X-Content-Type-Options = [nosniff],
X-Frame-Options = [SAMEORIGIN],
X-Request-Id = [XXXXXXXX],
X-Runtime = [0.089825]
]
Response body: 
Jul 11, 2023 5:25:24 AM FINE com.dabsquared.gitlabjenkins.util.CommitStatusUpdater
Project (90971) and commit (3ebaf5cdb93ee18913642e9155a66467a89cb7cf) combination not found

All the connections are valid and tested. Attaching the SCM setup as well for reference.

The pipeline script for reference:

pipeline {
    agent {
        node {
            label 'ubuntu'
        }
    }
    options {
        // sets the status of the pipeline depending on the pipeline _end_ results
        gitlabBuilds(builds: ["setup", "unit-tests", "integration-tests", "build", "security scan", "vulnerability scan", "e2e-test", "setup-multi-node-env", "e2e-join-test"])
    }
    environment {
        GOPRIVATE = 'gitlab.my-org.com/core-build'
    }
    stages {
        stage('setup') {
            steps {
                gitlabCommitStatus("setup") {
                    addGitLabMRComment(comment: "[Automatically generated message from Jenkins]  \nA new job is triggered on Jenkins:  \nURL: ${env.BUILD_URL}")
                    echo 'Setting up the environment'
                    sh "chmod +x -R ${env.WORKSPACE}"
                    sh 'ci/jenkins/setup/environment.sh'
                }
            }
        }
        stage('unit-tests') {
            steps {
                gitlabCommitStatus("unit-tests") {
                    script {
                        echo 'Running unit tests'
                        sh 'make test-coverage'
                        sh '/root/go/bin/gocov convert coverage-report.out | /root/go/bin/gocov-xml > coverage-report.xml'

                        archiveArtifacts artifacts: 'coverage-report.xml'
                        step([$class: 'CoberturaPublisher', coberturaReportFile: 'coverage-report.xml'])

                        def coverage = sh(
                            script: "go tool cover -func coverage-report.out | grep total | awk '{print \$3}'",
                            returnStdout: true
                        ).trim()
                        def coverageReportArtifactUrl = env.BUILD_URL + 'cobertura/'
                        addGitLabMRComment(comment: "Test coverage ${coverage} <br/>Coverage report: ${coverageReportArtifactUrl}")
                    }
                }
            }
        }
        stage('integration-tests') {
            steps {
                gitlabCommitStatus("integration-tests") {
                    script {
                        echo 'Running integration tests'
                        sh 'make integration-test'
                    }
                }
            }
        }
        stage('build') {
            steps {
                gitlabCommitStatus("build") {
                    echo 'Building bin'
                    sshagent(credentials: ['svc.edge-sshkey']) {
                        sh 'ci/jenkins/build-app.sh'
                    }
                    sh 'sudo bin version'
                }
            }
        }
        stage('security scan') {
            steps {
                gitlabCommitStatus("security scan") {
                    echo 'Running security checker scan'
                    echo 'install gosec tool'
                    sh 'curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.15.0'
                    sh "${env.WORKSPACE}/bin/gosec -fmt=json -out=gosecreport.json -exclude-dir=build -exclude-dir=test ./... || true"
                    junit(
                        allowEmptyResults: true,
                        testResults: 'gosecreport.xml'
                    )
                }
            }
        }
        stage('vulnerability scan') {
            steps {
                gitlabCommitStatus("vulnerability scan") {
                    echo 'Running static code security scan'
                    echo 'install govulncheck tool'
                    sh 'go install golang.org/x/vuln/cmd/govulncheck@v0.0.0-20230313161840-8a73a7e4f203'
                    timeout(time: 15, unit: 'MINUTES') {
                        sh '/root/go/bin/govulncheck  ./... > govulnreport.txt 2>&1 || true'
                    }
                    sh 'cat govulnreport.txt'
                }
            }
        }
        stage('e2e-test') {
            steps {
                gitlabCommitStatus("e2e-test") {
                    echo 'Running e2e tests'
                    sh 'make e2e-test'
                }
            }
        }
        stage('setup-multi-node-env') {
            steps {
                gitlabCommitStatus("setup-multi-node-env") {
                    echo 'Using vagrant to bring up 2 node cluster'
                    sh 'ci/jenkins/setup/multi-node.sh'
                }
            }
        }
        stage('e2e-join-test') {
            steps {
                gitlabCommitStatus("e2e-join-test") {
                    echo 'Running e2e tests for join'
                    sh 'KUBECONFIG=~/.kube/config make e2e-test-need-cluster'
                }
            }
        }
    }
    post {
        always {
            script {
                archiveArtifacts allowEmptyArchive: true, artifacts: 'govulnreport.txt'
                archiveArtifacts allowEmptyArchive: true, artifacts: 'gosecreport.json'
                def buildUrl = env.BUILD_URL
                def goVulnReportArtifactUrl = buildUrl + 'artifact/govulnreport.txt'
                def govulnReportLink = "<a href='${goVulnReportArtifactUrl}'>govulnreport.txt</a>"
                def gosecReportArtifactUrl = buildUrl + 'artifact/gosecreport.json'
                def gosecReportLink = "<a href='${gosecReportArtifactUrl}'>gosecreport.json</a>"
                if (currentBuild.currentResult == 'SUCCESS') {
                    addGitLabMRComment(comment: ":white_check_mark: ${env.JOB_NAME} :penguin: <b>Build</b> SUCCEEDED :muscle:<br/>Build results: [Jenkins [${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}]](${env.RUN_DISPLAY_URL})<br/>Commit: ${env.GIT_COMMIT}<br/>Govuln report: ${govulnReportLink}<br/>Gosec report: ${gosecReportLink}")
                }
                if (currentBuild.currentResult == 'FAILURE') {
                    addGitLabMRComment(comment: ":red_circle: ${env.JOB_NAME} :penguin: <b>Build</b> FAILURE  :worried:<br/>Build results: [Jenkins [${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}]](${env.RUN_DISPLAY_URL})<br/>Commit: ${env.GIT_COMMIT} <br/>Govuln report: ${govulnReportLink}<br/>Gosec report: ${gosecReportLink}")
                }
                if (currentBuild.currentResult == 'ABORTED') {
                    addGitLabMRComment(comment: ":interrobang: ${env.JOB_NAME} :penguin: <b>Build</b> ABORTED  :confused:<br/>Build results: [Jenkins [${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}]](${env.RUN_DISPLAY_URL})<br/>Commit: ${env.GIT_COMMIT}<br/>Govuln report: ${govulnReportLink}<br/>Gosec report: ${gosecReportLink}")
                }
                if (currentBuild.currentResult == 'UNSTABLE') {
                    addGitLabMRComment(comment: ":interrobang: ${env.JOB_NAME} :penguin: <b>Build</b> UNSTABLE  :confused:<br/>Build results: [Jenkins [${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME}]](${env.RUN_DISPLAY_URL})<br/>Commit: ${env.GIT_COMMIT}<br/>Govuln report: ${govulnReportLink}<br/>Gosec report: ${gosecReportLink}")
                }
            }
        }
    }
}

Any help to resolve this will be highly appreciated.

Hi @shubham14bajpai ,

Please double-check that the commit mentioned in the error message (3ebaf5cdb93ee18913642e9155a66467a89cb7cf) actually exists in the GitLab repository associated with project ID 90971. You can check this by navigating to the GitLab web interface and looking for the commit there.