如何使用声明性管道将sh输出分配给变量?
def arch_prefix() {
script {
return sh(script : 'uname -m', returnStdout: true).trim()
}
}
// end - Auxiliary fuctions
pipeline {
agent none
environment {
DOCKER_IMAGE = 'test'
ARCHITECTURE = arch_prefix()
DOCKER_IMG = "${DOCKER_IMAGE}-${ARCHITECTURE}"
}
stages {
stage('Build') {
parallel {
stage('arch1') {
agent { label 'agent_a' }
steps {
echo "${DOCKER_IMG}"
}
stage('arch2') {
agent { label 'agentb' }
steps {
echo "${DOCKER_IMG}"
}
}
}
}
}
}