Service Virtualization

Expand all | Collapse all

How to pass the configuration option for Virtual Services deployment in Jenkins Plugin? 

Jump to Best Answer
  • 1.  How to pass the configuration option for Virtual Services deployment in Jenkins Plugin? 

    Posted 11-28-2018 04:15 AM

    Hi all,

     

    Need some help on using Jenkins Plugin.

     

    I have a Virtual Service with three configuration files for different environments. 

    If its manual I can select the configuration file from the list before deploying it in to the VSE server.

     

    When I am using Jenkins Plugin to deploy the Virtual Services, I have to create the MAR file first and also while creating the MAR file I should select the config file and then we can deploy that MAR file into VSE using Jenkins.

     

    But my requirement is to pass that config file as option like a parameter in Jenkins to deploy instead of hardcoded to one config file in MAR file.

     

    Does anyone know how we can do this using Jenkins CA DevTest Plugin or some other way in Jenkins?

     

    Thanks,

    Satish



  • 2.  Re: How to pass the configuration option for Virtual Services deployment in Jenkins Plugin? 
    Best Answer

    Posted 11-28-2018 02:01 PM

    What version of DevTest are you using? Certain enhancements have been made in regards to our Jenkins plugin since 10.3.

     

    Are you currently creating the MAR file manually and then attempting to deploy the virtual service through the MAR file? And while deploying it through Jenkins, you want to pass in the configuration file as a parameter so that the virtual service gets deployed to that specific environment?

     

    If this is the case, one suggestion is to create three MAR files one with each configuration (manually or through our MakeMar.exe command line utility) and then in your Jenkins pipeline select the appropriate MAR file, out of the three you created, based on the configuration parameter.

     

    You could also create a MAR Info file, which can be used to create the MAR file. The MAR Info file contains all the information, such as the configuration to be used, for creating the MAR file. Here is an example of the content of a MAR file:

     

    <?xml version="1.0" ?>

    <MarInfo>
    <name>MyVirtualServiceName</name>
    <type>VIRTUAL_SERVICE</type>
    <projectRoot>MySVProjectName</projectRoot>
    <optimized>true</optimized>
    <deployInfo>
    <PrimaryAsset>VirtualServices/MyVirtualServiceName.vsm</PrimaryAsset>
    <Configuration>Configs/project.config</Configuration>
    <ConcurrentCapacity>1</ConcurrentCapacity>
    <ThinkTimePercent>100</ThinkTimePercent>
    <AutoRestart>true</AutoRestart>
    <StartOnDeploy>true</StartOnDeploy>
    </deployInfo>
    </MarInfo>

     

     

    The above bolded part is where you can change the configuration file to be included in the MAR. So during your Jenkins pipeline execution, you could potentially make a copy of this baseline MAR Info file and change that one line and replace it with a different config file. Then build your MAR file dynamically, using this MAR Info file and DevTest_HOME/bin/MakeMar.exe. Finally deploy the virtual service using the newly build MAR file.



  • 3.  Re: How to pass the configuration option for Virtual Services deployment in Jenkins Plugin? 

    Posted 12-12-2018 10:23 AM

    Thank you, William.



  • 4.  Re: How to pass the configuration option for Virtual Services deployment in Jenkins Plugin? 

    Posted 12-12-2018 12:36 PM

    There is another way to modify the configuration of the MAR File using the Virtual Service Invoke API - DevTest Solutions - 10.3 - CA Technologies Documentation 

     

    This can be easily automated using a Jenkins Pipeline 

     

    Key Steps - links are to the SWAGGER for 10.3 / 10.4 Virtual Service Invoke API 
    2. Get the MAR file either from SCM (GIT in the Example) or download from VSE (http://VSEServer:1505/lisa-virtualize-invoke/api/v2/swagger-ui#!/vses%7BvseId%7Dservices/getService)
    3. Create a Builder Session by REST POST (http:// VSEServer :1505/lisa-virtualize-invoke/api/v2/swagger-ui#!/VS_Builder_Session_info/addBuilderSession) 
    3. Get TransportProtocol ID  by REST GET
    4. Update Transport Protocol with Port (recordingEndpoint) you want. by REST PUT http://localhost:1505/lisa-virtualize-invoke/api/v2/swagger-ui#!/Transport_Protocol_info/updateTransportProtocol_1  Transport Protocol JSON Structure:
    tranportProtocolJSON= {"typeId": "HTTP", "basePath": "/", "useGateway": true, "hostHeaderPassThrough": false, "recordingEndpoint": {"host": "localhost", "port": "7114"}, "targetEndpoint": {"host": "localhost", "port": "51223"}}
    5.  Create the VS MAR File from the Builder Session (http:// VSEServer:1505/lisa-virtualize-invoke/api/v2/swagger-ui#!/VS_Builder_Session_info/getBuilderSession)