Using ItemListener.java

39 views
Skip to first unread message

Jim SERRA

unread,
Oct 15, 2015, 5:45:38 AM10/15/15
to Jenkins Developers
Hi,
I'm trying to use ItemListener.java to do actions after a job is deleted. I'm testing it by creating a random new file but it's not working:  


@Extension
public class UpdateTable extends ItemListener{
   
@Override
   
public void onDeleted(Item deletedItem) {
         
File file2 = new File("/var/lib/jenkins/the_test.txt");
       
try {
            file2
.createNewFile();
       
} catch (IOException ex) {
           
Logger.getLogger(UpdateTable.class.getName()).log(Level.SEVERE, null, ex);
       
}
   
}
}

Regards,

Jim.

Victor Martinez

unread,
Oct 15, 2015, 5:05:39 PM10/15/15
to Jenkins Developers
Hi,

  jobConfigHistory plugin uses that functionality, have you seen how it is used in that plugin?

Cheers

Jim SERRA

unread,
Oct 16, 2015, 3:44:10 AM10/16/15
to Jenkins Developers
Ok thanks! I will have a look at it.

Jim SERRA

unread,
Oct 16, 2015, 6:29:51 AM10/16/15
to Jenkins Developers
Hum strange I don't find my mistake.
Frustrating...
The logger doesn't return anything, It seems like it doesn't go in the listener after the delete.

Vincent Latombe

unread,
Oct 16, 2015, 10:04:11 AM10/16/15
to Jenkins Dev
If you're using eclipse, don't forget to call mvn clean hpi:run, and not mvn hpi:run (otherwise you're @Extension annotation is not picked up)

Vincent

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/d8d64438-9102-43da-98af-e167810549f4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jim SERRA

unread,
Oct 16, 2015, 10:28:26 AM10/16/15
to Jenkins Developers
Thanks ! It's working, I'm using Netbeans but I used to do build instead of clean and build, I didn't know @Extension need a clean

Jim,
Reply all
Reply to author
Forward
0 new messages