Jenkins multistage pipeline - level 4 fail

this is my pipeline script:

//

// Setup up the Remote connection for SSH Build Pipeline step

//

def remote = [:]

remote.name = 'ststor01'

remote.host = 'ststor01'

remote.user = 'natasha'

remote.password = 'Bl@kW'

remote.allowAnyHosts = true             

pipeline {

    // Run on agent with label 'ststor01'

    agent { label 'ststor01' }

    // Pipeline stages 

    stages {

        // Deploy stage

        stage('Deploy') {

            steps {

                echo 'Deploying ...'

                // Connect to GIT and download the repo code

                // Use the Jenkins Credentials by ID: GIT_CREDS

                git credentialsId: 'GIT_CREDS', url: 'http://git.stratos.xfusioncorp.com/sarah/web.git'

                // Transfer all the files we downloaded to /tmp of ststor01

                sshPut remote: remote, from: '.', into: '/tmp'

                // Finally move all the files from /tmp to /data on ststor01

                sshCommand remote: remote, command: "mv -f /tmp/${JOB_NAME}/* /data"

            }

        }

        // Test stage

        stage('Test') {

            environment {

                // Update the below value as per the text given in question

                INDEX_CONTENT = 'Welcome to xFusionCorp Industries'

            }

            steps {

                // Now test that the content from default page from HTTPD on each 

                // appservers is same as the index.html content required as

                sh '((curl http://stapp01:8080/ | grep -F "$INDEX_CONTENT") && true)'

                sh '((curl http://stapp02:8080/ | grep -F "$INDEX_CONTENT") && true)'

                sh '((curl http://stapp03:8080/ | grep -F "$INDEX_CONTENT") && true)'

            }

        }

    }

}

i try to setup storage server as build agent(install java etc) and use it to run the pipeline above.

and the fail msg of verification, i really dont know what to do:

Why are you running the pipeline on ststor01?
You deployment stage doesn’t copy the index file from the git repo to the application servers.
Also you seem to be using Jenkins to create the content. The task asks you to update the git repo.
For your test is it adequate to curl the endpoint and check for a 200. Also it asks you to check the load balancer and not the individual app servers.

this is my 2nd attempt, it gives me error msg - “did not deploy latest changes”

Please just share your Jenkinsfile.

pipeline {
    agent any
    
    stages {
        stage('Deploy') {
            steps {
                // Deploy the code from web repository to the Storage Server
                sh 'scp -o StrictHostKeyChecking=no -r /root@localhost:sarah/web.git/ natasha@ststor01:/var/www/html/'
            }
        }
        
        stage('Test') {
            steps {
                // Test if the website is accessible
                script {
                    sh 'curl -IsS http://stlb01:8091 | head -n 1 | grep 200'              
                }
            }
        }
    }
    
}

error msg:

deployment is not configured to deploy latest changes

You deployment stage doesn’t copy the index file from the git repo to the application servers.

hm but the /var/www/html dir on storage server is shared with all 3 app servers. i was thinking i could just copy to this shared dir.

Yes you are right:

a. The Deploy stage should deploy the code from web repository under /var/www/html on the Storage Server , as this location is already mounted to the document root /var/www/html of all app servers.