Edits history of script submission #10666 for ' Get pipeline values for a pipeline (circleci)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Circleci = {
    	token: string
    }
    /**
     * Get pipeline values for a pipeline
     * Returns a map of pipeline values by pipeline ID. For more information see the [pipeline values reference page](https://circleci.com/docs/variables/#pipeline-values).
     */
    export async function main(auth: Circleci, pipeline_id: string) {
    	const url = new URL(`https://circleci.com/api/v2/pipeline/${pipeline_id}/values`)
    
    	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