Reputation: 569
Here's my script:
environment {
REPORT = "${params.REPORT}"
DATE = sh(script: "echo `date +%F`", returnStdout: true).trim()
REPORTNAME = "${params.REPORT}-$DATE-report.csv"
EMAIL_RECIPIENTS = "[email protected]"
EMAIL_RECIPIENTS_DEBUG = "[email protected]";
EMAIL_PREFIX = "Serverless Cadence Report - ${params.REPORT}"
}
stages {
stage('Lambda Report Execution') {
when {
expression{REPORT == "lambda"}
}
steps {
container('aws-cli') {
sh '''
cd cadence/serverless/${REPORT}/
rm -f results.out
touch results.out
echo """Region,AccountID,Resource,Runtime,LastModified""">${REPORTNAME}
# aws configservice select-aggregate-resource-config --expression \\"SELECT accountId, awsRegion, resourceId, resourceName, configuration.runtime, configuration.lastModified WHERE resourceType = 'AWS::Lambda::Function'\\" --configuration-aggregator-name DelegatedAdminAggregator --profile my-profile --query \\"Results\\" --output text | tr '[:space:] '\n' > results.out
while read line;do
echo $line | jq -r '. | [.awsRegion, .accountId, .resourceName, .configuration.runtime, .configuration.lastModified]|@csv' >> $REPORTNAME
done<results.out
'''
}
}
}
}
No matter what I do, that echo line right in the middle gives the following error:
10:29:36 + echo Region,AccountID,Resource,Runtime,LastModified
10:29:36 /home/jenkins/agent/workspace/serverless-cadence-reporter@tmp/durable-2327237a/script.sh:
line 9: unexpected EOF while looking for matching `''
I tried single ", single ', double ", triple """. I tried escaping \", and "\"
Every time I get the error Unexpected EOF.
What am I doing wrong?
Upvotes: 0
Views: 37
Reputation: 569
the tr at the end of the long aws cli line contained an unmatched '. The trick is, groovy seems to ignore the commenting out of lines in shell blocks, or requires a different comment character.
Upvotes: 0