gpg error the following signatures couldn't be verified because the public key is not available code example

Example 1: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6494C6D6997C215E

Example 2: ubuntu 18.04 jenkins The following signatures couldn't be verified because the public key is not available:

Utils:

https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-18-04

https://pkg.jenkins.io/debian-stable/

Solve the problem by adding this:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -