Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Success Pull Request Comment is not send, while errors are working fine #637

Open
0ptaq0 opened this issue Jul 1, 2024 · 5 comments
Open

Comments

@0ptaq0
Copy link

0ptaq0 commented Jul 1, 2024

I am using sfdx hardis in my custom Gitlab pipeline.
Pipelines are running bounded to Merge Requests, 'Enable merged results pipelines' option is enabled >>
"This pipeline ran on the contents of the merge request combined with the contents of the target branch"

I have added following env variables:

  • CI_SFDX_HARDIS_GITLAB_TOKEN
  • MS_TEAMS_WEBHOOK_URL
  • JIRA_TOKEN
  • JIRA_HOST
  • JIRA_EMAIL
  • JIRA_TICKET_REGEX
  • JIRA_PAT = $JIRA_HOST //as we use JIRA Cloud version
  • CONFIG_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
  • ORG_ALIAS: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
  • DEPLOY_BRANCHES: /^(dev|sit|stage|production)$/

My validation/deployment command looks almost the same, only difference is --checkonly flag:

sfdx hardis:source:deploy --checkonly \
        --wait 300 \
        --testlevel $TEST_LEVEL \
        --manifest 'dx-delta/package/package.xml' \
        --ignorewarnings \
        --postdestructivechanges 'dx-delta/destructiveChanges/destructiveChanges.xml' \
        --verbose \
        --checkcoverage \
        --coverageformatters json-summary \
        --targetusername $SF_USERNAME

During deployment I would expect some success message posted to Merge Request comment and optionally to related JIRA in MR's description, but I am getting below:

Total Test Time:  3869366
=== Coverage or Junit Result Report Locations
Code Coverage formats, [json-summary], written to 0Af9X00000Zej0fSAB/coverage
Deploy Succeeded.
[sfdx-hardis] No commandsPostDeploy found to run
[sfdx-hardis] {"noPrData":""} && [object Object] && false
[sfdx-hardis] [Git Provider] Skip post pull request comment
[sfdx-hardis] hardis:source:deploy execution time 1:09:24.093

However, posting error comments works just fine:

Error (1): Deploy failed.
No sfdx-hardis tip to solve this error. Try google ?
[sfdx-hardis] No commandsPostDeploy found to run
[sfdx-hardis] [Git Provider] Try to post a pull request comment/note...
[sfdx-hardis] [Gitlab integration] Listing Notes of Merge Request...
[sfdx-hardis] [Gitlab integration] Adding Merge Request Note on Gitlab...
[sfdx-hardis] hardis:source:deploy execution time 0:07:17.252

And then I can see a comment with great tips on how to solve errors ;)

Also, nothing is posted to JIRA but that's a minor item, I would just need a success comment to Merge Request at this moment.

What am I missing?

@nvuillam
Copy link
Member

nvuillam commented Jul 1, 2024

@0ptaq0 that might be a bug :)
I investigate :)

@nvuillam
Copy link
Member

nvuillam commented Jul 1, 2024

There are many sfdx-hardis features embedded within hardis:project:deploy:sources:dx, including JIRA ones.

hardis:source:deploy currently only embeds the errors comment.

The corresponding call of your use case would be the following:

sfdx hardis:project:deploy:sources:dx --check \
        --packagexml 'dx-delta/package/package.xml' \
        --testlevel $TEST_LEVEL \
        --targetusername $SF_USERNAME

you would also need to define the following variables in your gitlab-ci.yml

  variables:
    SFDX_DEPLOY_WAIT_MINUTES=300
    PACKAGE_XML_TO_DELETE=dx-delta/destructiveChanges/destructiveChanges.xml

Please can you try to check if it works on your project ? :)

@nvuillam
Copy link
Member

nvuillam commented Jul 1, 2024

Additional note: after merge, if you use the following script, you will benefit of QuickDeploy :)

sfdx hardis:project:deploy:sources:dx \
        --packagexml 'dx-delta/package/package.xml' \
        --testlevel $TEST_LEVEL \
        --targetusername $SF_USERNAME

@0ptaq0
Copy link
Author

0ptaq0 commented Jul 2, 2024

Thank you Nicolas, JIRA integration now works like a charm :)

Regarding packagexml I needed to place it under ./manifest folder

I have only one issue with destructive changes, the env var PACKAGE_XML_TO_DELETE does not seem to take any effect. Also, like with packagexml I placed destructiveChanges.xml under ./manifest but also had no success, neither on validation nor deployment.

[sfdx-hardis] Empty package.xml: nothing to deploy
[sfdx-hardis] No deployment to perform
[sfdx-hardis] hardis:project:deploy:sources:dx execution time 0:00:06.365

My flow looks like this:

  1. Open Merge Request -> Validation starts
  2. Collecting approvals on peer code review
  3. Manually click Run Pipeline button on Merge Request which initiates deployment
  4. If Deployment is successful, then Merge Request is merged

SFDX Git Delta creates a diff package and package.xml + destructiveChanges.xml which I then archive and pass to sfdx-hardis.

Also as mentioned above I am using custom CICD and embedded sfdx-hardis so I do not have any .sfdx-hardis.yml in my repository, that may also be an issue?

As a workaround, I can also check if destructive Changes are not empty and then call yet another sfdx deployment command, but the best would be to fit everything in one shot ;)

@nvuillam
Copy link
Member

nvuillam commented Jul 2, 2024

@0ptaq0 do you know that sfdx-git-delta is also embedded within sfdx-hardis and project:source:deploy:dx ? :)

https://sfdx-hardis.cloudity.com/salesforce-ci-cd-config-delta-deployment/

I'm wondering if you are not trying to reproduce the standard sfdx-hardis pipeline :)

https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/ci/.gitlab-ci.yml

https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/ci/.gitlab-ci-config.yml

Can you compare with your pipeline ?

I feel the only difference is that

  • the deployment validation job is automatically run with sfdx-hardis when you create a MR
  • when you merge the MR, the deployment is processed (using QuickDeploy for better perfs ^^)

If you want, please share your gitlab-ci.yml and i'll tell you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants