How to define variable values for Import - VisualCron - Forum

Community forum

Dan Byrne
2019-11-18T13:52:02Z
Somewhat relating to how people are doing CI/CD for releasing jobs in Visual CRON (https://www.visualcron.com/forum.aspx?g=posts&t=6669), we are looking to use Import/Export, scripted using Powershell and the DLLs to run the Import.
The model of doing so is to export the particular job(s) and configuration sections of VisualCron, update the resulting XML files and set variable/parameter values where need be, then in the CI/CD tool (eg. Azure DevOps, Octopus Deploy, Jenkins, etc), you can define the variable values, which may be different per environment/server.

One challenge we face is that the Exported XMLs have what seems to be encoded/encrypted values inside the <ValueObject> tag for various string values, particularly Job Variables and Global Variables.
Job Variables and Global Variables are both what I would assume are the most obvious candidates for using a variable value that may be different between VisualCron servers/environments, so the values for these we want to 'variablise' within the CI/CD tool. To me it seems a bit odd that the Variable string is encoded, while plenty of other string values are not.

I guess we could build a script to forcibly set the variables after Import, but this also doesn't seem good practice, especially if the jobs are active directly after Import, which means they could immediately trigger with incorrect values prior to the variable-setting. Yes we can go in and manually update the variables, but that defeats the purpose of a fully automated CI/CD, plus also the risk as noted of having jobs run too soon before variable-update.

One of the suggestions from the earlier mentioned post is to use server environment variables, but given that means a Visualcron dependency on a configuration outside of Visualcron config it doesn't seem the nicest option.

Is there any way to programmatically calculate the required encrypted value for ValueObject to populate the variable string? or is this truly encrypted and therefore inaccessible?
Support
2019-11-19T15:04:34Z
You can use serverObj.Decrypt( or clientObj.Decrypt( in the API.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Dan Byrne
2019-11-20T02:14:37Z
Hi Henrik,

Thanks for the reply. Given that the output of serverObj.Encrypt() is a byte[], how do I convert this into an appropriate string that can be put into <ValueObject> tag inside the *.xml file (say Variables.xml) that can be used for import?

I have tried converting this byte[] to base64 and inserting that value, but it doesnt seem correct, when Import this I check the value it shows "Error displaying Variable: There is an error in XML document (1, 1)."... so do I need to XMLSerialise this first? I notices comments in this post:
https://www.visualcron.c....aspx?g=posts&t=5252 

that refers to:
task.VariableSet.UserVariable.ValueObject = ClientObj.Encrypt(SerializationHelper.XmlSerialize("TEST"))

However, ClientObj.Encrypt takes a string input, but SerializationHelper.XmlSerialize outputs byte[]... so are we to convert XMLSerialize byte[] to string (base64?) before Encrypt?
Once that is done, the encrypt job outputs byte[] also... so again is that base64 converted to string before we put in to the import file?

FYI I tried this and it didnt seem to produce correct values - I'm getting two errors on that variable value now.
Scroll to Top