简体   繁体   中英

how i can get the number of build and the revision of some project in jenkins?

i want get this information from jenkins for use them in other application , this other application will have just a table with the follow information:

Nombre Proyecto -- Liga a la documentacion del proyecto -- # Build -- # revision Maven project 1 http: ..... 20 20

but how can i get the # of build and revision.

I find some way to get it, is by the files that are in each project: 1.- nextBuilderNumber : with this file i can get the # build 2.- scm-polling.log:with this file i can get the # of revision

but with the file 1 i'm having problems because the file number 1 don't have extension, but in properties it say's that is a plaint text object, so i can't read it. but if i change the extension of the file now it works. but when jenkins compile the project again generate the file without extension.

this is the part of the source code for read the file:

enter code here for (int i = 0; i < enlaces.length; i++) {
        try {         
            fr = new FileReader (ruta+enlaces[i]+"/nextBuildNumber.txt");         
            br = new BufferedReader(fr);         
            int numeroBuild;
            numeroBuild=new Integer(br.readLine()); 
            orderList[i]=new Datos(enlaces[i],numeroBuild,10);                                                    
            }
        catch(Exception e){
            e.printStackTrace();
        }finally{            
        try{                               
            fr.close();                                  
           }catch (Exception e2){ 
                e2.printStackTrace();
           }
        }               
    }        

Jenkins already set some variables in the environment, you can use them. From the wiki :

When a Jenkins job executes, it sets some environment variables that you may use in your shell script, batch command, Ant script or Maven POM 1. The following table contains a list of all of these environment variables.

There's the BUILD_NUMBER and SVN_REVISION , for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM