Here, the idea is to create a formula on Ritchie that will return the tool selected by the user according to its profile.
You’ll find more information about the conditional field on the config.json inputs section.
rit get tools
.This formula must have (at least) three input parameters. See below:
RIT_NAME
).RIT_PROFILE
).RIT_TOOL
).The formula inputs must follow the diagram below:
Search for the config.json
file of your formula and replace it the inputs
field for the block below:
{
"label": "Type the professional name: ",
"name": "rit_name",
"type": "text",
"cache": {
"active": true,
"newLabel": "Type other name: ",
"qty": 3
}
},
{
"label": "Select the professional profile: ",
"name": "rit_profile",
"type": "text",
"items": [
"BACK-END",
"FRONT-END",
"OPERATION",
"QA"
]
},
{
"condition": {
"variable":"rit_profile",
"operator":"==",
"value":"BACK-END"
},
"label": "Which tool this BACK-END professional needs to install: ",
"name": "rit_tool",
"type": "text",
"items": [
"INTELLIJ",
"DATAGRIP",
"DOCKER"
]
},
{
"condition": {
"variable":"rit_profile",
"operator":"==",
"value":"FRONT-END"
},
"label": "Which tool this FRONT-END professional needs to install: ",
"name": "rit_tool",
"type": "text",
"items": [
"ATOM",
"CHROME DEV TOOLS",
"NPM"
]
},
{
"condition": {
"variable":"rit_profile",
"operator":"==",
"value":"OPERATION"
},
"label": "Which tool this OPERATION professional needs to install: ",
"name": "rit_tool",
"type": "text",
"items": [
"JENKINS",
"CIRCLE-CI",
"TERRAFORM"
]
},
{
"condition": {
"variable":"rit_profile",
"operator":"==",
"value":"QA"
},
"label": "Which tool this QA professional needs to install: ",
"name": "rit_tool",
"type": "text",
"items": [
"SELENIUM",
"POSTMAN",
"CUCUMBER"
]
}
]
Follow the steps below to create your formula:
Search for the main
file of tour formula and extract all the inputs before using them to call your formula’s method. See some code example below:
import os
from formula import formula
name = os.environ.get("RIT_NAME")
profile = os.environ.get("RIT_PROFILE")
tool = os.environ.get("RIT_TOOL")
formula.run(profile, tool)
package com.ritchie;
import com.ritchie.formula.Formula;
public class Main {
public static void main(String[] args) {
String username = System.getenv("RIT_GIT_USER");
String token = System.getenv("RIT_GIT_TOKEN");
String email = System.getenv("RIT_GIT_EMAIL");
Formula formula = new Formula(username, token, email);
System.out.println(formula.run());
}
}
main.*
nomenclature for most languages, except Node that it calls index.js
.Search for the formula
file of your formula and implement the method performing the operation of your automation. See some code examples:
def run(name, profile, tool):
printf("Welcome to {name}")
printf("He is our new {profile} professional.")
printf("Ritchie will install {tool} for him automatically.")
package com.ritchie.formula;
import com.google.gson.*; # Add GSON dependency on POM.XML
public class Formula {
private String username;
private String token;
private String email;
public String run() {
Gson gson = new Gson();
return gson.toJson(this, Formula.class);
}
public Formula(String username, String token, String email) {
this.username = username;
this.token = token;
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
pom.xml
for Java, requirements.txt
for Python, package.json
for Node, go.mod
for Golang, etc).~ rit get tools
? Type the professional name: Dennis
? Select the professional profile: BACK-END
? Which tool this BACK-END professional needs to install: DOCKER
Welcome to Dennis
He is our new BACK-END professional.
Ritchie will install DOCKER for him automatically.
~ rit get tools --rit_name="Dennis" --rit_profile="BACK-END" --rit_tool="DOCKER"
Welcome to Dennis
He is our new BACK-END professional.
Ritchie will install DOCKER for him automatically.
If you want to test your formula more, see a suggestion below:
👉 If you’ve completed the second tutorial, go to the fourth How to group formulas.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.