Using the latest JFrog products?
JFrog Platform User Guide


JFrog Mission Control 3.x Documentation
To get the latest version, go to the JFrog Unified Platform


Skip to end of metadata
Go to start of metadata

Overview

Mission Control provides you the flexibility of using placeholders in configuration scripts so that the user can enter user input when the scripts are applied.

The REST API supports this capability through theGet Script User InputREST API call.

Running a Script with User Input

Running a script with user input through the REST API is done through the following main steps:

  1. Run theGet Script User InputREST API endpoint on the script.
    This will return a JSON object specifying the user input required
  2. Modify thenameproperty of the required user input fields in the JSON object
  3. Run theExecute ScriptREST API endpoint passing in the modified user input JSON object as input
Page Contents


Examples

The following examples show how to run scripts through the REST API with user input.

Example 1 - Modifying a Repository

The following script modifies thedescriptionfield of a local repository called "my-repository" in an Artifactory service called "Denver" according to user input. Assume the script is calledmodify-description

artifactory('Denver'){ localRepository("my-repository") { description userInput ( type : "STRING", value : "This is a generic description", description : "Please provide a description" ) } }
  1. Call Get Script User Input
    To get the user input required for the script, you need to make the following REST API call:

    $ curl -XGET 'http://localhost:8080/api/v3/scripts/modify-description/user_inputs' -uadmin:password

    This will return the following JSON object:

    {" ArtifactoryDsl # 0 # LocalRepositoryDsl # 0 # description#0": { "name": "description", "description": "Please provide a description", "value": "This is a generic description", "type": "STRING", "multivalued": false } }

  2. Execute the script with the modified user input value

    $ curl -XPUT 'http://localhost:8080/api/v3/execute_script/modify-description' -uadmin:password -H 'Content-Type: application/json; charset=UTF-8' -T scriptinput.json

    where we pass in the script input JSON object as the following file:

    scriptinput.json
    {" ArtifactoryDsl # 0 # LocalRepositoryDsl # 0 # description#0": "*** This is my new description ***" }
  3. This produces the following output:

    [ { "instance": { "name": "Denver", "url": "http://artifactory-adi.jfrogdev.co/artifactory", "type": "ARTIFACTORY" }, "status": "OK", "execution_duration": 514, "operation": "UPDATE_REPOSITORY" } ]

Example 2 - Selecting the Artifactory Service to Modify

在这个例子中,我们将修改的描述a local repository as in the previous example, however we will also receive the Artifactory service on which to make the change as user input. Assume the script is calledmodify-description-select-service

name = userInput ( type : "STRING", value : "Insert Artifactory Name", description : "Please provide Service name" ) artifactory(name){ localRepository("my-repository") { description userInput ( type : "STRING", value : "This is a generic description", description : "Please provide a description" ) } }

  1. Call Get Script User Input

    $ curl -XGET 'http://localhost:8080/api/v3/scripts/modify-description-select-service/user_inputs' -uadmin:password

    This will return the following JSON object:

    { "McDsl#0#name#0": { "name": "name", "description": "Please provide Service name", "value": "Insert Artifactory Name", "type": "STRING", "multivalued": false }, "ArtifactoryDsl#0#LocalRepositoryDsl#0#description#0": { "name": "description", "description": "Please provide a description", "value": "This is a generic description", "type": "STRING", "multivalued": false } }
  2. Execute the script with the modified user input value

    $ curl -XPUT 'http://localhost:8080/api/v3/execute_script/modify-description-select-service' -uadmin:password -H 'Content-Type: application/json; charset=UTF-8' -T scriptinput.json

    where we pass in the script input JSON object as the following file:

    scriptinput.json
    { "McDsl#0#name#0": "Denver", "ArtifactoryDsl#0#LocalRepositoryDsl#0#description#0": "description for local repository" }


  • No labels