src/Model/Project.php
public function setVariable(
        $name,
        $value,
        $json = false,
        $visibleBuild = true,
        $visibleRuntime = true,
        $sensitive = false
    ) {
        // If $value isn't a scalar, assume it's supposed to be JSON.
        if (!is_scalar($value)) {
            $value = json_encode($value);
            $json = true;
        }
        $values = [
            'value' => $value,
            'is_json' => $json,
            'visible_build' => $visibleBuild,
            'visible_runtime' => $visibleRuntime];
        if ($sensitive) {
            $values['is_sensitive'] = $sensitive;
        }

        $existing = $this->getVariable($name);
        if ($existing) {
            return $existing->update($values);
        }

        $values['name'] = $name;

        return ProjectLevelVariable::create($values, $this->getLink('#manage-variables'), $this->client);
    }
public function setVariable(
        $name,
        $value,
        $json = false,
        $visibleBuild = true,
        $visibleRuntime = true,
        $sensitive = false
    ) {
        // If $value isn't a scalar, assume it's supposed to be JSON.
        if (!is_scalar($value)) {
            $value = json_encode($value);
            $json = true;
        }
        $values = [
            'value' => $value,
            'is_json' => $json,
            'visible_build' => $visibleBuild,
            'visible_runtime' => $visibleRuntime];
        if ($sensitive) {
            $values['is_sensitive'] = $sensitive;
        }

        $existing = $this->getVariable($name);
        if ($existing) {
            return $existing->update($values);
        }

        $values['name'] = $name;

        return ProjectLevelVariable::create($values, $this->getLink('#manage-variables'), $this->client);
    }
public function setVariable ( $ name , $ value , $ json = false , $ visibleBuild = true , $ visibleRuntime = true , $ sensitive = false ) { // If $value isn't a scalar, assume it's supposed to be JSON. if ( ! is_scalar ( $ value ) ) { $ value = json_encode ( $ value ) ; $ json = true ; } $ values = [ 'value' => $ value , 'is_json' => $ json , 'visible_build' => $ visibleBuild , 'visible_runtime' => $ visibleRuntime ] ; if ( $ sensitive ) { $ values [ 'is_sensitive' ] = $ sensitive ; } $ existing = $ this -> getVariable ( $ name ) ; if ( $ existing ) { return $ existing -> update ( $ values ) ; } $ values [ 'name' ] = $ name ; return ProjectLevelVariable :: create ( $ values , $ this -> getLink ( '#manage-variables' ) , $ this -> client ) ; }
Set a variable.

@param string $name
The name of the variable to set.
@param mixed  $value
The value of the variable to set.  If non-scalar it will be JSON-encoded automatically.
@param bool $json
Whether this variable's value is JSON-encoded.
@param bool $visibleBuild
Whether this this variable should be exposed during the build phase.
@param bool $visibleRuntime
Whether this variable should be exposed during deploy and runtime.
@param bool $sensitive
Whether this variable's value should be readable via the API.

@return Result
Set a variable .