Jenkins Installation on Azure Cloud but getting W: GPG error
I was trying to install the Jenkins instance on Azure Cloud. While doing the installation of Jenkins I faced a few issues and took me a few hours even days to fix the installation. I am not going to tell here how you create VM and other stuff in the Azure Cloud rather I am telling here direct Jenkins installation commands that you can street forward use it.
Good YouTube Tutorial So far I have found https://www.youtube.com/watch?v=ahEdad8fdi8
So once you install the VM on your Azure Cloud and connect via SSH following command: ssh -i <private key path> azureuser@1.1.1.1. You will reach to below command interface as the root user. Please note that in your case cmd/terminal interface might be different. So check the above video link I have shared.
First, update the default Ubuntu packages lists for upgrades with the following command:
sudo apt-get update
Then, run the following command to install JDK 11:
sudo apt-get install openjdk-11-jdk
Now, we will install Jenkins itself. Issue the following four commands in sequence to initiate the installation from the Jenkins repository:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Here you probably get an error message like below:
Now if you do
sudo apt update or sudo apt-get update
Below output you will get:
azureuser@azure-jenkins:~$ sudo apt update
Hit:2 http://azure.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://azure.archive.ubuntu.com/ubuntu focal-security InRelease
Ign:1 https://pkg.jenkins.io/debian-stable binary/ InRelease
Get:6 https://pkg.jenkins.io/debian-stable binary/ Release [2044 B]
Get:7 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Ign:7 https://pkg.jenkins.io/debian-stable binary/ Release.gpg
Reading package lists... Done
W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5SSSSSSSSA
E: The repository 'http://pkg.jenkins.io/debian-stable binary/ Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Here you will see two points
W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5SSSSS1D57EF5
E: The repository 'http://pkg.jenkins.io/debian-stable binary/ Release' is not signed.
Now follow these below commands:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 57EFDDDDDDD
Here --recv-keys 57EFFSSSSS (my one).
your case you can get from above two points mentioned.
So lets say for now your command is:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 57EFDDDDDDD
You will get below success output:
Executing: /tmp/apt-key-gpghome.b9JU2dr8f3/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 57EFDDDDDDD
gpg: key 57EFDDDDDDD: public key "Jenkins Project <jenkinsci-board@googlegroups.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
Once that’s done, start the Jenkins service with the following command:
sudo systemctl start jenkins.service
To confirm its status, use:
sudo systemctl status jenkins
Output:
If the above output does not give your httpPort=8080 then this Optional with Jenkins installed, we can proceed with adjusting the firewall settings. By default, Jenkins will run on port 8080. In order to ensure that this port is accessible, we will need to configure the built-in Ubuntu firewall (ufw). You can also add security inbound rules from Azure Cloud inside the VM that you created. You can find this info also from the above YouTube link I mentioned.
To open the 8080 port and enable the firewall, use the following commands:
sudo ufw allow 8080
sudo ufw enable
Once done, test whether the firewall is active using this command:
sudo ufw status
Finally, you Jenkins ready on your Azure vmVM public IP with port 8080
An example: http://10.21.21.20:8080/
With the firewall configured, it’s time to set up Jenkins itself. Type in the IP of your EC2 along with the port number. The Jenkins setup wizard will open.
To check the initial password, use the cat command as indicated below:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Then continue to finish your Jenkins instance…..
Reference: https://askubuntu.com/questions/660599/i-am-installing-jenkins-server-but-its-giving-w-gpg-error
#jenkins #bash #ubuntu #azure #cloud #devops