If statement is not working in yaml script

Hi Team,

I am new to Gitlab and writing gitlab script where i am facing some problem with if else statement in gitlab script.
Please find below script
deploy_dev:
stage: deploy
script:
- $ARTIFACT_DIR = “C:\GitLab-Runner\Artifact”
- if ( “$deptName” == “IT” ); then
|
$CType = “application/json”
$Auth = @{
deptName = “$deptName”
usernameOrEmailAddress = “$env:USER_GADMIN”
password = “$env:PWD_GADMIN”
} | ConvertTo-Json
else
|
$CType = “application/json”
$Auth = @{
usernameOrEmailAddress = “$env:USER_GADMIN”
password = “$env:PWD_GADMIN”
} | ConvertTo-Json
fi
- echo $Auth

For above condition getting error like below
At C:\windows\TEMP\build_script650698425\script.ps1:309 char:30
00:00

  • if ( “$deptName” == “IT” ); then | $CType = “application/json” $A …
  •                          ~
    

Missing statement block after if ( condition ).
At C:\windows\TEMP\build_script650698425\script.ps1:309 char:40

  • if ( “$deptName” == “IT” ); then | $CType = “application/json” $A …
  •                                    ~~~~~~
    

Expressions are only allowed as the first element of a pipeline.
At C:\windows\TEMP\build_script650698425\script.ps1:309 char:68

  • … ptName" == “IT” ); then | $CType = “application/json” $Auth = @{ te …
  •                                                         ~~~~~
    

Unexpected token ‘$Auth’ in expression or statement.

Please help me on above error

This post was flagged by the community and is temporarily hidden.