Search in sources :

Example 6 with Variable

use of org.gitlab4j.api.models.Variable in project octane-gitlab-service by MicroFocus.

the class GitLabAPiClientImpl method getInstanceVariables.

public List<Variable> getInstanceVariables() {
    List<Variable> variableList = new ArrayList<>();
    try {
        URL url = this.getApiUrl(INSTANCE_VARIABLES_PATH);
        Response r = this.get(null, url);
        if (r.getStatus() == Response.Status.OK.getStatusCode()) {
            return VariablesHelper.convertJSONArrayToVariables(new JSONArray(r.readEntity(String.class)));
        } else {
            log.info("no variables are found, status code is" + r.getStatus());
        }
    } catch (IOException e) {
        log.error("getting error when trying to get instance variables", e);
    }
    return variableList;
}
Also used : Response(javax.ws.rs.core.Response) Variable(org.gitlab4j.api.models.Variable) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) IOException(java.io.IOException) URL(java.net.URL)

Example 7 with Variable

use of org.gitlab4j.api.models.Variable in project choerodon-starters by open-hand.

the class PipelineApi method updatePipelineScheduleVariable.

/**
 * Update a pipeline schedule variable.
 *
 * <pre><code>GitLab Endpoint: PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key</code></pre>
 *
 * @param projectIdOrPath projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
 * @param pipelineScheduleId the pipelineSchedule ID
 * @param key the key of an existing pipeline schedule variable
 * @param value the new value for the variable
 * @return a Pipeline instance with the updated variable
 * @throws GitLabApiException if any exception occurs during execution
 */
public Variable updatePipelineScheduleVariable(Object projectIdOrPath, Integer pipelineScheduleId, String key, String value) throws GitLabApiException {
    GitLabApiForm formData = new GitLabApiForm().withParam("value", value, true);
    Response response = this.putWithFormData(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "pipeline_schedules", pipelineScheduleId, "variables", key);
    return (response.readEntity(Variable.class));
}
Also used : Response(javax.ws.rs.core.Response) Variable(org.gitlab4j.api.models.Variable)

Aggregations

Variable (org.gitlab4j.api.models.Variable)7 ArrayList (java.util.ArrayList)4 Response (javax.ws.rs.core.Response)3 CIParameter (com.hp.octane.integrations.dto.parameters.CIParameter)2 ApplicationSettings (com.microfocus.octane.gitlab.app.ApplicationSettings)2 IOException (java.io.IOException)2 URL (java.net.URL)2 Collectors (java.util.stream.Collectors)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 GitLabApi (org.gitlab4j.api.GitLabApi)2 GitLabApiException (org.gitlab4j.api.GitLabApiException)2 CIPluginServices (com.hp.octane.integrations.CIPluginServices)1 OctaneConfiguration (com.hp.octane.integrations.OctaneConfiguration)1 DTOFactory (com.hp.octane.integrations.dto.DTOFactory)1 CIProxyConfiguration (com.hp.octane.integrations.dto.configuration.CIProxyConfiguration)1 CIBuildStatusInfo (com.hp.octane.integrations.dto.general.CIBuildStatusInfo)1 CIJobsList (com.hp.octane.integrations.dto.general.CIJobsList)1 CIPluginInfo (com.hp.octane.integrations.dto.general.CIPluginInfo)1 CIServerInfo (com.hp.octane.integrations.dto.general.CIServerInfo)1