Below are my build instructions for GnuPG 2.2.9, released on July 12th, 2018. These instructions are built for a headless Centos 7 LTS server (specificaly the openshift/base-centos7 docker image).
You use the below install script to install GnuPG 2.2.x by running the following commands:
# if you are root in a docker image:
curl -OL "https://gist.githubusercontent.com/simbo1905/ba3e8af9a45435db6093aea35c6150e8/raw/83561e214e36f6556fd6b1ec0a384cf28cb2debf/install-gnupg22.sh" && bash ./install-gnupg22.sh
# else if you need to sudo to do the installs:
curl -OL "https://gist.githubusercontent.com/simbo1905/ba3e8af9a45435db6093aea35c6150e8/raw/83561e214e36f6556fd6b1ec0a384cf28cb2debf/install-gnupg22.sh" && sudo -H bash ./install-gnupg22.sh
Here is some code which maybe helpful for you in inserting versions if you wanted different ones.
export libgpg_error_version="1.47"
export libgcrypt_version="1.10.3"
export libassuan_version="2.5.6"
export libksba_version="1.6.5"
export npth_version="1.6"
export pinentry_version="1.2.1"
export gnupg_version="2.4.4"
sudo yum-builddep -y gnupg2
gpg --list-keys
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 249B39D24F25E3B6 04376F3EE0856959 2071B08A33BD3F06 8A861B1C7EFD60D9