Multi-agent systems have proved to be a suitable technology for developing self-adaptive Internet of Things (IoT) systems, able to make the most appropriate decisions to address unexpected situations. This leads to new opportunities to use multi-agent technologies to develop all kinds of cyberphysical systems, which usually encompass a high diversity of devices (e.g., new home appliances). The heterogeneity of devices and the high diversity of the available technology, demand the explicit modeling of all kinds of variability for ultra-large systems. However, multi-agent systems lack mechanisms to effectively deal with the different degrees of variability present in these kinds of systems. Software Product Line (SPL) technologies, including variability models, have been successfully applied to different domains to explicitly model variability in hardware, system requirements or userintended goals. In addition, current market trends are unpredictable, imposing novel technologies, new requirements and goals that must be incorporated immediately into the running systems without damaging them. In this paper, we combine goal-driven and SPL approaches to develop and drive the evolution of multi-agent systems in the context of cyber-physical systems. We propose an SPL process and an evolution process that define a set of models (iStar 2.0 for goals and CVL models for variability) and algorithms to automatically propagate changes to agents running in multiple heterogeneous devices, each of them with a different configuration. We illustrate the proposal in the context of a home energy management system. Finally, we have tested the scalability and performance of the proposal using randomly generated models. The results show that with our approach it is possible to manage huge iStar models of 10000 elements in seconds.