Snippets

Adaptavist Get and Set Project Propertys

Created by Kristian Walker last modified
/*
 * This script provides some example code that can be run on the console in Jira cloud and shows how to get and set project properties..
 * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner 
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." 
*/

// Add the key of your project below
def projectKey ="Demo"

// Specify the value below to be stored in the project property
def valueToUpdate = "Demo Value"

// Specify below the name of your project property
def projectPropertyName = "demo-project-property"


// Example to Update a Project Property
// Note if the project property does not exist it will get created.
    def updateProjectProprty = put("/rest/api/3/project/${projectKey}/properties/${projectPropertyName}")
            .header('Content-Type', 'application/json')
            .body([
                    demoValue: valueToUpdate
            ])
            .asString()
            .statusText

// Example to get a project property
    def getProjectProprty = get("/rest/api/3/project/${projectKey}/properties/${projectPropertyName}")
            .header('Content-Type', 'application/json')
            .asObject(Map)
            .body
            .value
            .demoValue


Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.