`Syntax error: "(" unexpected` error in jenkinsfile with docker agent

agent {
    docker {
        image 'maven:3.6.3-adoptopenjdk-14'
        args '-v $HOME/.m2:/root/.m2'
    }
}
stage('build and push docker image'){
    steps{
        echo 'build docker image start'
        sh '''
        echo $SHELL;
        _dir1=$PWD;
        shortnames=('admin' 'auth-server' 'gateway' 'monitor')
        for shortname in ${shortnames[@]}
        do
        module=microservice-$shortname
        cp $_dir1/$module/target/*.jar $_dir1/_docker/$module/;
        cd $_dir1/_docker/$module/;
        docker buildx build --platform linux/amd64,linux/arm64 -t microservice/$shortname:${BRANCH_NAME} -t microservice/$shortname:${BRANCH_NAME}-${BUILD_NUMBER} --push .
        done
        '''
        echo 'build docker image success'
    }
}

同样的配置之前跑没有问题(jenkins on host,war包部署)。
后来,因为迁移选择了docker部署,job跑在docker中。就出现了Syntax error: "(" unexpected的问题

[Pipeline] sh
[Pipeline] sh
+ echo

+ _dir1=/var/jenkins_home/workspace/micro-test_jenkins_docker
/var/jenkins_home/workspace/micro-test_jenkins_docker@tmp/durable-88dfb50e/script.sh: 4: Syntax error: "(" unexpected
[Pipeline] }
[Pipeline] // stage

诡异的是我脚本中加了echo $SHELL. 但日志处打印出的是空白内容。

但是

[root@192-168-50-88 micro-test_jenkins_docker@tmp]# docker run --rm -it maven:3.6.3-adoptopenjdk-14 echo $SHELL
/bin/bash

各位,有清楚问题在哪的么?