Edits history of script submission #10678 for ' List all environment variables (circleci)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Circleci = {
    	token: string
    }
    /**
     * List all environment variables
     * Returns four 'x' characters, in addition to the last four ASCII characters of the value, consistent with the display of environment variable values on the Circleci website.
     */
    export async function main(auth: Circleci, project_slug: string) {
    	const url = new URL(`https://circleci.com/api/v2/project/${project_slug}/envvar`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			'Circle-Token': auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 536 days ago