This answer did not help me
Below is the method in groovy:
def analyze(repoName){
result= sh (
script: '''
cd ${WORKSPACE}/${BUILD_NUMBER}
cat > sonar-project.properties << EOF_$$
sonar.projectKey=ABC-$repoName
sonar.projectName=ABC
sonar.projectBaseDir=${WORKSPACE}/${BUILD_NUMBER}
EOF_$$
''',
returnStatus: true
) == 0
print "Creating file - Return status: ${result}"
}
where below line gives error:
sonar.projectKey=ABC-$repoName
properties file gets created with entry sonar.projectKey=ABC-
How to use groovy variable in sh()
step?