Started by user admin [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/jenkins_home/workspace/wordpress-update-pipeline [Pipeline] { [Pipeline] withCredentials Masking supported pattern matches of $MYSQL_CREDENTIALS or $MYSQL_CREDENTIALS_PSW or $SSH_CREDENTIALS or $SSH_CREDENTIALS_PSW [Pipeline] { [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Setup SSH Known Hosts) [Pipeline] sh + mkdir -p /root/.ssh + ssh-keyscan -H 192.168.1.147 # 192.168.1.147:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.5 # 192.168.1.147:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.5 # 192.168.1.147:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.5 # 192.168.1.147:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.5 # 192.168.1.147:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.5 [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Pre-backup Health Check) [Pipeline] script [Pipeline] { [Pipeline] sh + curl -o /dev/null -s -w %{http_code} http://192.168.1.147:8080/ [Pipeline] echo WordPress is up and running! [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Backup WordPress) [Pipeline] sshagent [ssh-agent] Using credentials jenkins (SSH key for Server 2 access) $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-XXXXXXC1Ac4e/agent.759 SSH_AGENT_PID=763 Running ssh-add (command line suppressed) Identity added: /var/jenkins_home/workspace/wordpress-update-pipeline@tmp/private_key_16808072460273735983.key (jenkins@server2) [ssh-agent] Started. [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh + echo Ensuring backup directory exists... Ensuring backup directory exists... + ssh jenkins@192.168.1.147 [ ! -d ~/wordpress_backups ] && mkdir -p ~/wordpress_backups || echo 'Backup directory already exists' Backup directory already exists + echo Backing up WordPress files... Backing up WordPress files... + ssh jenkins@192.168.1.147 docker exec wordpress-stack-wordpress-1 tar -czf /tmp/wordpress_files_backup.tar.gz -C /var/www/html . && docker cp wordpress-stack-wordpress-1:/tmp/wordpress_files_backup.tar.gz ~/wordpress_backups/ + echo Dumping WordPress database... Dumping WordPress database... + ssh jenkins@192.168.1.147 docker exec wordpress-stack-db-1 mysqldump -u exampleuser -p**** exampledb > ~/wordpress_backups/wordpress_backup.sql --no-tablespaces mysqldump: [Warning] Using a password on the command line interface can be insecure. + echo Copying backups to Jenkins workspace... Copying backups to Jenkins workspace... + scp jenkins@192.168.1.147:~/wordpress_backups/wordpress_backup.sql . + scp jenkins@192.168.1.147:~/wordpress_backups/wordpress_files_backup.tar.gz . + echo Stopping WordPress container... Stopping WordPress container... + ssh jenkins@192.168.1.147 docker stop wordpress-stack-wordpress-1 wordpress-stack-wordpress-1 [Pipeline] } [Pipeline] // script [Pipeline] } $ ssh-agent -k unset SSH_AUTH_SOCK; unset SSH_AGENT_PID; echo Agent pid 763 killed; [ssh-agent] Stopped. [Pipeline] // sshagent [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Verify WordPress Image) [Pipeline] sshagent [ssh-agent] Using credentials jenkins (SSH key for Server 2 access) $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-XXXXXXkUmMiI/agent.815 SSH_AGENT_PID=818 Running ssh-add (command line suppressed) Identity added: /var/jenkins_home/workspace/wordpress-update-pipeline@tmp/private_key_6472595031937795288.key (jenkins@server2) [ssh-agent] Started. [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh + ssh jenkins@192.168.1.147 docker inspect wordpress-stack-wordpress-1 --format='{{.Image}}' > ~/current_image_id [Pipeline] sh + ssh jenkins@192.168.1.147 docker inspect --format='{{.Image}}' wordpress-stack-wordpress-1 [Pipeline] sh + ssh jenkins@192.168.1.147 docker inspect --format='{{.Id}}' wordpress:latest [Pipeline] echo Current WordPress Image ID: sha256:f4c026a8ee03f4401eb2651b711685f9f02f3a34bd883651e8b747a8bd2886ba [Pipeline] echo Latest WordPress Image ID: sha256:f4c026a8ee03f4401eb2651b711685f9f02f3a34bd883651e8b747a8bd2886ba [Pipeline] sh + ssh jenkins@192.168.1.147 docker start wordpress-stack-wordpress-1 wordpress-stack-wordpress-1 [Pipeline] } [Pipeline] // script [Pipeline] } $ ssh-agent -k unset SSH_AUTH_SOCK; unset SSH_AGENT_PID; echo Agent pid 818 killed; [ssh-agent] Stopped. [Pipeline] // sshagent [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Pull Latest WordPress and Restart) Stage "Pull Latest WordPress and Restart" skipped due to when conditional [Pipeline] getContext [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Health Check) Stage "Health Check" skipped due to when conditional [Pipeline] getContext [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Rollback on Failure) Stage "Rollback on Failure" skipped due to when conditional [Pipeline] getContext [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Declarative: Post Actions) [Pipeline] echo Pipeline completed at 2025-01-05 15:31:33 [Pipeline] script [Pipeline] { [Pipeline] echo ************************************************************* WordPress is already at the latest version (sha256:f4c026a8ee03f4401eb2651b711685f9f02f3a34bd883651e8b747a8bd2886ba) No upgrade was necessary at this time. ************************************************************* [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // withCredentials [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS