Not able to create a new environment variable from one of the stage

pipeline {
    agent any
    options {
        gitlabBuilds(builds: ['Install Dependencies', 'Eslint'])
    }
    stages {
        stage('SCM checkout') {
            steps {
                checkout([
                    $class: 'GitSCM', 
                    branches: [[name: "origin/${env.gitlabSourceBranch}"]],
                    userRemoteConfigs: [[ 
                        credentialsId: '',
                        url: ''
                    ]]
                ])
            }
        }
        stage('Install Dependencies') {
            steps {
                gitlabCommitStatus("Install Dependencies") {
                    sh '''
                        npm ci
                    ''' 
                }
            }
        }
        stage('Run Tests') {
            parallel {
                stage('Eslint') {
                    steps {
                        gitlabCommitStatus("Eslint") {
                            script {
                                env.ESLINT_OUTPUT = sh(
                                    returnStdout: true,
                                    script: 'npm run lint -- --format html'
                                )
                            }
                        }
                    }
                }
            post {
                always {
                    addGitLabMRComment comment: "${env.ESLINT_OUTPUT}"
                }
            }
        }
    }
}

the value for env.ESLINT_OUTPUT is coming as null
what am i doing wrong ? can someone help me make this work. btw new to jenkins
note: i might have messed up some curly braces here, please ignore that

since your already doing scripted block, why not use a try { … } finally { } instead of the post { } block. I’m wondering if either a) the post is on the wrong step, so trying to run in parallel before eslint finishes, or some synchronisation issue in parallel.