Skip to end of banner
Go to start of banner

How to print out all project keys

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In this article you will find out how to write a script which will loop through all existing projects and save all project name and project keys to a .csv file.

  1. First of all you have to assign allProjects() to a string which you will use to access all projects that you have in Jira.

string allpro = allProjects();

  1. Then you have to create a file where all projects keys will be saved. You can also add a column “Project name” and “Project key” for clarification.

//create a file with columns first
printInFile("sheet1.csv", + "Project Name " + "  Project Key  ");

  1. Now you have to loop through all existing projects. For this we will use admProjectProperties(pkey) method.

//loop through all existing projects here
for(int x = 0; x < size(allpro); x++){

    JProject prj = admProjectProperties(allpro.getElement(allpro, x)); // get project Key
    printInFile("sheet1.csv", prj.name + " " + prj.key ); // save data to a file
    runnerLog("Project Name : " + prj.name + "   Project Key : " + prj.key);

}

  1. After you create above script and run it, you should see all project names and keys in Editor console.Additionally a .csv file will be created with name “sheet1.csv” on the left in your Files.

You can also edit this script and adjust it to your needs using other data that is available to return when using admProjectProperties more details here :

admProjectProperties

Final code should look like this :

string allpro = allProjects();

//create a file with columns first
printInFile("sheet1.csv", + "Project Name " + "  Project Key  ");

//loop through all existing projects here
for(int x = 0; x < size(allpro); x++){

    JProject prj = admProjectProperties(allpro.getElement(allpro, x)); // get project Key
    printInFile("sheet1.csv", prj.name + " " + prj.key ); // save data to a file
    runnerLog("Project Name : " + prj.name + "   Project Key : " + prj.key);

}

 

  • No labels