-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
In CI/CD YAML scripts, Skip Deployments/Destructive if package.xml is an empty placeholder #154
Comments
Hi @WaseemAliSabeel ! Thanks for this very well described request! And for your interest in the plugin. What I understand is that you would like to have a way to detect if package.xml or destructiveChanges.xml are empty in order to not execute the deploy in those cases, right ? If this is the case you might be interested in a tool like xq which allow you to write jq query on xml. Ex: # returns "null" or the list of types
$xq . < changed-sources/destructiveChanges.xml | jq '.Package.types | if type=="array" then .[] else . end' I hope it helps |
Thank you for following up, @scolladon !
Can you please assist me in using these libraries or plugins as expected in the YAML execution steps ? Output of output of |
Ok, After a little bit digging around-
jq version = jq-1.6 Now, when I execute your stated
The first two cat commands both display an empty placeholder xml file, with no types in them, It triggers the SFDX deployment Job and errors out saying - "Cannot Convert undefined or null to object" And on a different try, the SFDX deployment command executed with the empty package.xml and it read on Setup->Deployment Status in the salesforce org - Can you @scolladon help troubleshoot this and help me with appropriate script commands which would lead to - Thanks! |
Hi, Something you could try is (I have not testing it myself) : $ cat changed-sources/package/package.xml
$ cat changed-sources/destructiveChanges/destructiveChanges.xml
$ PACKAGE=`xq . > changed-sources/package/package.xml | jq '.Package.types | if type=="array" then.[] else . end'`
$ echo "****** Deploying added and modified metadata ******"
$ [[ ! -z "$PACKAGE" ]] && sfdx force:source:deploy --checkonly --json --verbose --loglevel fatal --targetusername CI-SBX -x changed-sources/package/package.xml
$ echo "****** Deleting removed metadata ******"
$ DESTRUCTIVE=`xq . > changed-sources/destructiveChanges/destructiveChanges.xml | jq '.Package.types | if type=="array" then.[] else . end'`
$ [[ ! -z "$DESTRUCTIVE" ]] && sfdx force:mdapi:deploy --checkonly --json --loglevel fatal --targetusername CI-SBX --deploydir changed-sources/destructiveChanges You could also use grep to find if there is a type in the xml files (simpler and more easy to setup because it does not need setup installation) : $ cat changed-sources/package/package.xml
$ cat changed-sources/destructiveChanges/destructiveChanges.xml
$ echo "****** Deploying added and modified metadata ******"
$ [[ ! -z $(grep '<types>' changed-sources/package/package.xml) ]] && sfdx force:source:deploy --checkonly --json --verbose --loglevel fatal --targetusername CI-SBX -x changed-sources/package/package.xml
$ echo "****** Deleting removed metadata ******"
$ [[ ! -z $(grep '<types>' changed-sources/destructiveChanges/destructiveChanges.xml) ]] && sfdx force:mdapi:deploy --checkonly --json --loglevel fatal --targetusername CI-SBX --deploydir changed-sources/destructiveChanges if you need more help please use gitter (this is more suitable for direct communication). I close this issue then ! |
Thank You for your inputs @scolladon
Thanks again. Great Plugin! Keep it active ! |
@WaseemAliSabeel which CI are you using? I'm trying to implelent the exact same check using Github Actions but
|
@jonny-harte I guess you should be using Because the package xml is structured like-
When I implemented this plugin, I was using Screwdriver CICD tool https://screwdriver.cd/ |
@WaseemAliSabeel When there is any deletion , I can see the changes in destructiveChanges/destructiveChanges.xml file , In my logs , i could see below 0/0 . Is it correct ? Can u please share ,how it looks alike for your destructive deployments . |
Is your proposal related to a problem?
Yes, to avoid Deployments and Destructives where the package.xml or destructiveChanges.xml is just an empty placeholder with no metadata type contents in it.
Description - While using this Fantastic tool in a CI/CD automated pipeline, I have configured the steps in a YAML file as instructed in Repo's Readme.
An observation is that whenever in any of our delta commits, if we are changing any file outside of force-app folder, the sfdx sgd:source:delta command works as expected(which is great!) and it leads to generation of an empty placeholder
package.xml
and an empty placeholderdestructiveChanges.xml
in the changed-sources Output directory.Even this is fine and expected behaviour.
However, now, when we execute the commands to perform
sfdx:force:source:deploy
for delta deployment & subsequentlysfdx force:mdapi:deploy
for destructive deployment, it triggers an Empty Deployment job and we can see the Jobs running in Setup-> Deployment Status with 0/0 components.Describe the solution you'd like
The desired solution would be to see if the generated files (specifically destructiveChanges.xml file) are an empty placeholder just like -
without any Metadata Types in it, can we conditionally control to Not Execute
sfdx force:mdapi:deploy
for destructive deployment ?And on similar lines, if the output
package.xml
file is also like this empty placeholder, how to not execute thesfdx:force:source:deploy
command for the same ?I understand that this is not inherently part of the Plugin as such because the plugin did its job perfectly to find metadata deltas and it was as expected.
But in case of empty metadata deltas identified in these contexts, how to not Execute the deployment commands in a CI/CD pipeline using YAML scripts ?
Any thoughts / YAML code snippets around this ask please ?
Describe alternatives you've considered
None.
At the moment, as part of my Script In the Image shared, a second deployment job fires for the generated empty placeholder
destructiveChanges.xml
file.Additional context
This Ask / Enhancement Request is in regards of using the sfdx-git-delta plugin in a CI/CD pipeline context with no manual intervention.
The text was updated successfully, but these errors were encountered: