def call(String description) { // Initialize or increment a global step counter kept in the environment def current = (env.STEP_COUNTER ?: '0').trim() int next try { next = current.toInteger() + 1 } catch (Throwable ignored) { next = 1 } env.STEP_COUNTER = next.toString() // Derive environment name from common env vars def stageEnv = env.cicd_environment ?: env.INFRA_ENV ?: env.BUILD_ENV ?: env.ENVIRONMENT ?: 'ftr' return "[${stageEnv}] [Step ${env.STEP_COUNTER}] ${description}" }