Command line parameters are not being read in the uploadArchives task (pom properties)


I’m trying to pass an argument from command line into the uploadArchives task to upload artifacts into nexus. The issue is the pom groupid is not able to resolve the command line argument properly.

uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.archives

        repository(url: ""){
		  if (project.hasProperty('upload')) {
		   authentication(userName: "${userName}", password: "${password}")
        addFilter('artifact1') {artifact, file ->
   == 'artifact1'
		addFilter('artifact2') {artifact, file ->
   == 'artifact2'
        println "**** Inside uploading archives for ${environment}"

        pom('artifact1').version = '1.0-SNAPSHOT'
  //pom('artifact1').artifactId = '1.0-SNAPSHOT'
  pom('artifact1').groupId = 'com.ngs.dcd.${environment}'

I get an error at this line pom(‘artifact1’).groupId = ‘com.ngs.dcd.${environment}’ where $environment argument is not being resolved. I also see it doesn’t throw any error and it is printing fine in the above print statement. The issue is only when passing in pom groupid. Not sure if the arguments cannot be passed into the pom properties or is there any special syntax with this