Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@azu
Last activeJanuary 6, 2023 06:28
    • Star(3)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist
    Save azu/533a1cfb83e1040d77b6963c9004856d to your computer and use it in GitHub Desktop.
    Get Circle CI Project envars! Require Node.js 16 + `npm install node-fetch`
    importfetchfrom"node-fetch";// Node.js 18 just remove line
    constCIRCLECI_TOKEN=process.env.CIRCLECI_TOKEN
    constORG_NAME=process.env.ORG_NAME
    constfetchProjectList=(orgName=ORG_NAME)=>{
    returnfetch(`https://circleci.com/api/v2/insights/gh/${orgName}/summary`,{
    headers:{"Circle-Token":`${CIRCLECI_TOKEN}`}
    }).then(res=>res.json()).then(json=>json.all_projects);
    };
    constfetchProjectEnv=(orgName,project)=>{
    returnfetch(`https://circleci.com/api/v2/project/gh/${orgName}/${project}/envvar`,{
    headers:{"Circle-Token":`${CIRCLECI_TOKEN}`}
    }).then(res=>res.json());
    }
    constprojectNames=awaitfetchProjectList();
    constprojectMap=newMap()
    for(constprojectNameofprojectNames){
    constenv=awaitfetchProjectEnv(ORG_NAME,projectName);
    projectMap.set(projectName,env.items);
    }
    console.log(JSON.stringify(Array.from((projectMap.entries()))))
    @azu
    Copy link
    Author

    azu commentedJan 5, 2023

    $ CIRCLECI_TOKEN=xxx ORG_NAME=your-org node all-env-circleci.mjs

    @azu
    Copy link
    Author

    azu commentedJan 5, 2023

    Note: insights API does not return all projects.
    If you need to get all projecs, please copy these from Admin Console.

    @azu
    Copy link
    Author

    azu commentedJan 6, 2023

    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp