How to get exact corresponding http Jenkins workspace path?

I need to email following path after Jenkins build is completed -

http://<ip>:8080/job/Nightly_Build/51/execution/node/64/ws/

Using BUILD_URL environment variable, I can get path till http://<ip>:8080/job/Nightly_Build/51. Remaining path we can hardcode except value 64 in above path which keep changes when I make changes in pipeline code.

I am unable to get that value on the fly.

Can someone explain what is that 64 number in the path and how can it be retrieved using Jenkins environment variable or APIs?

See example pipeline below:

import org.jenkinsci.plugins.workflow.actions.WorkspaceAction
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker
import org.jenkinsci.plugins.workflow.graph.FlowNode

pipeline {
    agent any

    stages {
        stage('Create') {
            steps {
                deleteDir()
                sh 'date +%F%T >> ts.txt'
                //requires badge-plugin >= 2.x
                addBadge id: 'myBadgeId', icon: 'symbol-hourglass-outline plugin-ionicons-api', text: 'Timestamp',
                        link: link('ts.txt')
            }
        }
        stage('Work') {
            steps {
                echo "Hourglas symbol in job history linking to ts.txt now"
                sleep 30
            }
        }
        stage('Clean') {
            steps {
                removeBadges(id: 'myBadgeId')
            }
        }
    }
}


/*
Create a link to a file in a current workspace.
Note: presume this won't work for parallel stages

Signatures for Script Security:
method hudson.model.Actionable getAction java.lang.Class
method org.jenkinsci.plugins.workflow.graph.FlowNode getId
method org.jenkinsci.plugins.workflow.job.WorkflowRun getExecution
method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild
new org.jenkinsci.plugins.workflow.graph.FlowGraphWalker org.jenkinsci.plugins.workflow.flow.FlowExecution
staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods findAll java.lang.Object groovy.lang.Closure
*/

String link(String file) {
    List<String> ids = new FlowGraphWalker(currentBuild.rawBuild.execution).findAll { FlowNode n ->
        (n instanceof StepStartNode) && n.getAction(WorkspaceAction)
    }*.id
    return ids.isEmpty() ? null : "${env.BUILD_URL}execution/node/${ids.first()}/ws/${file}"
}