Search code examples
jenkinsjenkins-pipelineartifact

archiveArtifacts a specific file depending on build parameters


I want to archive a specific JSON file that's name depends on the parameter passed in build, but I get the error WorkflowScript: 42: unexpected char: '`' what's the correct way to go about this?

archiveArtifacts artifacts: `closureV2_${params.env.split('/')[3]}.json`, onlyIfSuccessful: false

Would .split('/')[3] even work in a jenkinsfile?


Solution

  • For Jenkinsfile which uses Groovy as program language, Groovy not use ` for string expression.

    Please change to

    "closureV2_${params.env.split('/')[3]}.json"