Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
How get the variable configuration for custom variable with an action?
-
Within my custom extension I often have the need to refer to the properties set via the editor for my ArtifactoryVersionVariable within actions, predicates, etc. Is there a better way to get this or is parsing the xml as I'm doing below as good as it gets?
internal static ArtifactoryVersionVariable GetVariableDeclaration(int applicationId, string artifactoryVariableName) { // Get variable properties var settings = StoredProcs .Variables_GetVariableDeclarations("B", applicationId, null) .Execute() .Where(s => s.Variable_Name == artifactoryVariableName) .FirstOrDefault() .Variable_Configuration; XmlDocument xml = new XmlDocument(); xml.LoadXml(settings); return new ArtifactoryVersionVariable { RepositoryKey = xml.SelectSingleNode("//Properties/@RepositoryKey").Value, RepositoryPath = xml.SelectSingleNode("//Properties/@RepositoryPath").Value, Filter = xml.SelectSingleNode("//Properties/@Filter").Value, TrimFromPath = xml.SelectSingleNode("//Properties/@TrimFromPath").Value, ReplaceSlashWithDot = bool.Parse(xml.SelectSingleNode("//Properties/@ReplaceSlashWithDot").Value), DefaultToNotIncluded = bool.Parse(xml.SelectSingleNode("//Properties/@DefaultToNotIncluded").Value) }; }Product: BuildMaster
Version: 4.6.4 -
Anything with the suffix
_Configurationcan be deserialized, so for your example all you need is:return (ArtifactoryVersionVariable)Util.Persistence .DeserializeFromPersistedObjectXml(settings);
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login