A population that adapts to gradual environmental change will typically experience temporal variation in its population size and the selection pressure. Based on the mathe- matical theory of inhomogeneous branching processes, we present a framework to describe the fixation process of a single beneficial allele under these conditions. The approach al- lows for arbitrary time-dependence of the selection coefficient s(t) and the population size N(t), as may result from an underlying ecological model. We derive compact ana- lytical approximations for the fixation probability and the distribution of passage times for the beneficial allele to reach a given intermediate frequency. We apply the formalism to several biologically relevant scenarios, such as linear or cyclic changes in the selection coefficient, and logistic population growth. Comparison with computer simulations shows that the analytical results are accurate for a large parameter range, as long as selection is not very weak.