Variables usage in pipeline file

Usage of variables in the place of service name

I am new to GitLab, I defined a variable and i wanted to use that variable name in the place of service name in few stages

stages:
- build
- test
- analysis

variables:
    MYSERVICE: test-project-name

build:image
     stage:build
## code for build

scan_cx:
    stage:test
  image:
    name: image_name 
  script:
    - /CxConsolePlugIn/runxCx scan -v -ProjectName "test\myprojects\$MYSERVICE-service" -CXServer https://someurl.com

in the above step i have used variable “MYSERVICE” in the place of my project name (test-project-name), i also wanted to append -service along with that basically concatenate with the value from varaible

I have also tried as below

    - /CxConsolePlugIn/runxCx scan -v -ProjectName "test\myprojects\${MYSERVICE}-service" -CXServer https://someurl.com

I have seen some concatenating examples but none of them worked, the pipeline is failing always

Below is the error

[2020-09-10 18:59:56,298 INFO ] Project name is myprojects${MYSERVICE}-service
[2020-09-10 18:59:56,300 INFO ] Logging into Checkmarx server.
[2020-09-10 18:59:56,560 INFO ] Login was completed successfully
[2020-09-10 18:59:56,593 INFO ] Team: “\test” was not found in server
[2020-09-10 18:59:56,594 ERROR] Error executing SAST scan command: Failed to initialize SAST scan prerequisites: Team: “\test” was not found in server
[2020-09-10 18:59:56,595 INFO ] CxConsole session finished
[2020-09-10 18:59:56,595 ERROR] Failure - General error occurred - error code 1

The pipeline is getting succeeded if i use the actual name in the place of variable as shown below

    - /CxConsolePlugIn/runxCx scan -v -ProjectName "test\myprojects\test-project-name-service" -CXServer https://someurl.com

Have a look here, may be this applies to your use case.

It should have quotes around it.

variables:
    MYSERVCE: "test-project-name"

You should then be able to use the variable like this:

 script:
     - /CxConsolePlugIn/runxCx scan -v -ProjectName "test\myprojects\${MYSERVICE}-service" -CXServer https://someurl.com

Thank you @melissa it still failed