Okay, so publications can be divided (roughly) into two general categories, and they are very different so let's treat them separately:
- 2nd or 3rd (or even later) Authorship: This is a project in which you played a supporting role but did not have creative control over it. The first author is responsible for the pace of this project, and there's nothing you can do to get it published if they're sitting on their hands.
- Primary authorship: You have direct control over whether you put out a first-author paper. They require more work but will be significantly more impressive on your CV. Here are the factors that determine if you will put one of these out:
1. Your ability to convince your PI that a) you have a sophisticated understanding of the lab's current research and b) are a hard worker. No PI will think, "Hm, I've got an intelligent hard-worker here who could put out a publication for my lab, but I'd rather they autoclave pipette tips and empty the tissue culture waste flasks."
2. Your skill at designing experiments that test a hypothesis, instead of nebulous experiments that at best can be considered "panning for gold." If, at the end of each week, you cannot say that you have new data that is directly relevant to your hypothesis, then you need to take more care in your experimental design. Of great value too, is being able to design experiments to efficiently kill a project if it is not moving along, instead of letting it eat up several more months of your life.
3. While research should always allow for the revision of a project as new data come to light, try to put together a rough idea of what the figures in your paper will look like earlier rather than later. This framework can change as the project runs its course, but if you're thinking in terms of your future publication's figures, step#2 will become much easier.
4. The amount of time you are willing to commit to the lab. Can you tell your buddies, "sorry I can't come to the bar, I've got a 10pm timepoint on Friday?"
Yes, undergraduate publication is difficult and rare, but it is not impossible. Prior to joining a lab, you can ask the PI what your tragectory looks like. If you're still washing dishes a couple months in, switch to a new lab.
Just my 2 cents.