public class CloudifyPluginUtilities extends Object
Constructor and Description |
---|
CloudifyPluginUtilities() |
Modifier and Type | Method and Description |
---|---|
static CloudifyEnvironmentData |
createEnvironment(hudson.model.TaskListener listener,
hudson.FilePath workspace,
co.cloudify.rest.client.CloudifyClient client,
String blueprintId,
String deploymentId,
Map<String,Object> inputs,
String outputsLocation,
boolean echoInputs,
boolean echoOutputs,
boolean debugOutput) |
static CloudifyEnvironmentData |
createEnvironment(hudson.model.TaskListener listener,
hudson.FilePath workspace,
co.cloudify.rest.client.CloudifyClient client,
String blueprintId,
String deploymentId,
String inputs,
String inputsLocation,
String mapping,
String mappingLocation,
String outputsLocation,
boolean echoInputs,
boolean echoOutputs,
boolean debugOutput)
Create a Cloudify environment.
|
static Map<String,Object> |
createInputsMap(hudson.FilePath workspace,
hudson.model.TaskListener listener,
String inputsText,
String inputsFile,
String mapping,
String mappingFile)
Given inputs in the form of a string, and in a form of a file, return a
Map of combined inputs. |
static void |
deleteEnvironment(hudson.model.TaskListener listener,
co.cloudify.rest.client.CloudifyClient client,
String deploymentId,
long pollingInterval,
Boolean ignoreFailure,
boolean debugOutput)
Delete an environment.
|
static String |
expandString(hudson.EnvVars envVars,
String value)
Expand a string input, for variables.
|
static Map<String,Object> |
getCombinedMap(hudson.FilePath workspace,
String filename,
String str,
Map<String,?> map)
Returns a combined map from file contents, string contents and an actual
Map . |
static <T extends com.cloudbees.plugins.credentials.common.IdCredentials> |
getCredentials(String credentialsId,
Class<T> credentialsClass,
hudson.model.Run<?,?> run) |
static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials |
getCredentials(String credentialsId,
hudson.model.Run<?,?> run) |
static co.cloudify.rest.helpers.ExecutionFollowCallback |
getExecutionFollowCallback(boolean printLogs,
boolean debugOutput,
co.cloudify.rest.client.CloudifyClient cloudifyClient,
PrintStream jenkinsLog)
Get an
ExecutionFollowCallback instance based on user parameters. |
static javax.json.JsonObject |
jsonFromMap(Map<String,Object> map) |
static String |
parseInput(String s,
hudson.util.VariableResolver<String> resolver)
Process a UI input string, by replacing macros in it and trimming it.
|
static Map<String,Object> |
readYamlOrJson(hudson.FilePath path)
Reads a JSON file from a
FilePath . |
static <T> Map<String,T> |
readYamlOrJson(hudson.FilePath workspace,
String contentsFile,
String contents)
Creates a
Map from a combination of a file and string contents. |
static Map<String,Object> |
readYamlOrJson(String str)
Read a YAML or a JSON from a string.
|
static String |
toString(javax.json.JsonObject json)
Convert a JSON to a string.
|
protected static void |
transform(Map<String,String> mapping,
Map<String,Object> result,
Map<String,Object> source) |
static void |
transformOutputsFile(hudson.FilePath outputsFile,
Map<String,Map<String,String>> mapping,
Map<String,Object> results)
Transform a standard outputs/capabilities file by using a mapping.
|
static hudson.util.FormValidation |
validateStringIsYamlOrJson(String value)
Validates whether a string is a valid YAML or JSON.
|
static void |
writeBoundObject(Object object,
hudson.FilePath outputFile)
Write a JAXB-annotated object to a file as JSON.
|
static void |
writeJson(javax.json.JsonObject object,
hudson.FilePath path)
Writes a JSON object to a
FilePath . |
public static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials getCredentials(String credentialsId, hudson.model.Run<?,?> run)
public static <T extends com.cloudbees.plugins.credentials.common.IdCredentials> T getCredentials(String credentialsId, Class<T> credentialsClass, hudson.model.Run<?,?> run)
public static Map<String,Object> getCombinedMap(hudson.FilePath workspace, String filename, String str, Map<String,?> map) throws IOException, InterruptedException
Map
.workspace
- path to workspacefilename
- name of file to read map fromstr
- string to parse for parametersmap
- of parameters, to add to the resultant mapIOException
- A problem occurred accessing the map fileInterruptedException
- The build was interrupted during executionpublic static String parseInput(String s, hudson.util.VariableResolver<String> resolver)
null
.s
- some stringresolver
- build's variable resolvernull
if the result was nothing.public static co.cloudify.rest.helpers.ExecutionFollowCallback getExecutionFollowCallback(boolean printLogs, boolean debugOutput, co.cloudify.rest.client.CloudifyClient cloudifyClient, PrintStream jenkinsLog)
ExecutionFollowCallback
instance based on user parameters.printLogs
- should event/logs be printed?debugOutput
- should debug-level logs be printedcloudifyClient
- REST clientjenkinsLog
- Jenkins' log streamExecutionFollowCallback
to use.public static void writeBoundObject(Object object, hudson.FilePath outputFile) throws IOException, InterruptedException
object
- object to serializeoutputFile
- file to write toIOException
- Some I/O error has occured.InterruptedException
- The build was interrupted during executionpublic static void writeJson(javax.json.JsonObject object, hudson.FilePath path) throws IOException, InterruptedException
FilePath
.object
- JSON object to writepath
- path to write toIOException
- Some problem occured during serialization.InterruptedException
- The build was interrupted during executionpublic static Map<String,Object> readYamlOrJson(hudson.FilePath path) throws IOException, InterruptedException
FilePath
.path
- path to the resourceIOException
- May be thrown by underlying framework.InterruptedException
- May be thrown by underlying framework.public static Map<String,Object> readYamlOrJson(String str)
str
- some stringJSONObject
containing the parsed data.public static <T> Map<String,T> readYamlOrJson(hudson.FilePath workspace, String contentsFile, String contents) throws IOException, InterruptedException
Map
from a combination of a file and string contents.workspace
- build's workspace rootcontents
- YAML/JSON contents, as a string (may be
null
)contentsFile
- workspace location of a YAML/JSON file (may be
null
, may not exist)Map
.IOException
- Thrown by underlying code.InterruptedException
- Thrown by underlying code.protected static void transform(Map<String,String> mapping, Map<String,Object> result, Map<String,Object> source)
public static void transformOutputsFile(hudson.FilePath outputsFile, Map<String,Map<String,String>> mapping, Map<String,Object> results) throws IOException, InterruptedException
outputsFile
- file containing outputsmapping
- mapping structureresults
- Map
to populate with resultsIOException
- problem occurred reading the outputs fileInterruptedException
- The build was interrupted during executionpublic static Map<String,Object> createInputsMap(hudson.FilePath workspace, hudson.model.TaskListener listener, String inputsText, String inputsFile, String mapping, String mappingFile) throws IOException, InterruptedException
Map
of combined inputs.workspace
- Jenkins' build workspacelistener
- Jenkins' task listenerinputsText
- inputs as a string, in YAML/JSON format (may be
null
)inputsFile
- inputs as a YAML/JSON file (may be null
)mapping
- inputs mapping, as a YAML/JSON string (may be
null
)mappingFile
- inputs mapping, as a YAML/JSON file (may be
null
)Map
representing combined inputs.IOException
- Thrown by underlying code.InterruptedException
- Thrown by underlying code.public static CloudifyEnvironmentData createEnvironment(hudson.model.TaskListener listener, hudson.FilePath workspace, co.cloudify.rest.client.CloudifyClient client, String blueprintId, String deploymentId, Map<String,Object> inputs, String outputsLocation, boolean echoInputs, boolean echoOutputs, boolean debugOutput) throws IOException, InterruptedException
IOException
InterruptedException
public static CloudifyEnvironmentData createEnvironment(hudson.model.TaskListener listener, hudson.FilePath workspace, co.cloudify.rest.client.CloudifyClient client, String blueprintId, String deploymentId, String inputs, String inputsLocation, String mapping, String mappingLocation, String outputsLocation, boolean echoInputs, boolean echoOutputs, boolean debugOutput) throws IOException, InterruptedException
listener
- Jenkins task listenerworkspace
- Jenkins workspace locationclient
- Cloudify client objectblueprintId
- blueprint IDdeploymentId
- deployment IDinputs
- deployment inputsinputsLocation
- location of file containing deployment inputsmapping
- YAML/JSON string containing input mappingsmappingLocation
- location of input mappings fileoutputsLocation
- location of outputs fileechoInputs
- whether to echo the deployment's inputs to the build
logechoOutputs
- whether to echo outputs to the build logdebugOutput
- whether to emit debug-level loggingCloudifyEnvironmentData
instance containing information
about the new environment.IOException
- Percolated from called code.InterruptedException
- Percolated from called code.public static void deleteEnvironment(hudson.model.TaskListener listener, co.cloudify.rest.client.CloudifyClient client, String deploymentId, long pollingInterval, Boolean ignoreFailure, boolean debugOutput) throws IOException, InterruptedException
listener
- Jenkins task listenerclient
- Cloudify client objectdeploymentId
- deployment IDpollingInterval
- number of milliseconds to wait between polling
iterationsignoreFailure
- whether to ignore failures during deletiondebugOutput
- emit debug statementsIOException
- Percolated from called codeInterruptedException
- Percolated from called codepublic static hudson.util.FormValidation validateStringIsYamlOrJson(String value)
value
- value to checkFormValidation
instance representing the result.public static String toString(javax.json.JsonObject json)
JsonGenerator
on Jenkins' logger, however JsonGenerator
closes the stream when it's JsonGenerator.close()
method is called.
That causes Jenkins' log to stop working.json
- JSON object to convert to a string.Copyright © 2016–2020. All rights reserved.