1

I'm new to Azure Devops and yaml.

We have a CI/CD process running that deploys to Salesforce. As long as the deployment runs completely, the script interprets this as a success, even if the deployment returns an error result.

Current setup:

- script: |
        if [ $(setvarStep.PullRequest) = 'true' ]
            then
                echo 'DevOps Message -- Validation in Progress - Non Feature branch behavior'
                npx sfdx force:source:deploy  --checkonly --testlevel $(setvarStep.SalesforceTestLevel) --sourcepath $(salesforce.sourcepath) --targetusername $(salesforce.connectedApp.Alias)
        fi

What I'd like to do is capture the result in a variable and check for an error message in the result, and throw an error in the script, however, everytime I try to check for the error, the if block returns "no error found"

- script: |
        if [ $(setvarStep.PullRequest) = 'true' ]
            then
                echo 'DevOps Message -- Validation in Progress - Non Feature branch behavior'
                sfdxresult=$(npx sfdx force:source:deploy  --checkonly --testlevel $(setvarStep.SalesforceTestLevel) --sourcepath $(salesforce.sourcepath) --targetusername $(salesforce.connectedApp.Alias)) 


       if ($sfdxresult-like "*Component Failures*")
           then
               echo "found the error!"
           else 
               echo "no error found!"
            fi
        fi            

Any advice?

4
  • Did you try to print the $sfdxresult? First see if the expected output is shown. Commented Dec 24, 2019 at 10:29
  • @massie yes, I've printed out $sfdxresult (I removed my debugging for succinctness) and see the full deployment result, including the "Component Failures" string I'm checking for Commented Dec 24, 2019 at 10:43
  • stackoverflow.com/questions/4467735/… this should be the solution Commented Dec 24, 2019 at 10:49
  • Thank you, that was it! Commented Dec 24, 2019 at 14:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.