Day 78: Jenkins Conditional Pipelin

Hi everyone,

I’m working on the Jenkins Pipeline Deployment task (deploying the web_app repository to the Nautilus App Server) and my pipeline runs successfully, but the lab validator still fails with the error:

“Validation file not found on App Server.”

Here is what I configured:

  • Created a Jenkins pipeline job named devops-webapp-job (not a multibranch pipeline).
  • Added a string parameter BRANCH.
  • Added a Jenkins agent named App Server 1 with label stapp01 and remote root directory /home/sarah/jenkins_agent.
  • The repository already exists on the server at /var/www/html.
  • Apache is running on port 8080.

My pipeline script:

pipeline {
    agent { label 'stapp01' }

    parameters {
        string(name: 'BRANCH', defaultValue: 'master', description: 'Branch to deploy')
    }

    stages {
        stage('Deploy') {
            steps {
                sh """
                cd /var/www/html
                git reset --hard
                git clean -fd
                git fetch origin
                git checkout ${params.BRANCH}
                git pull origin ${params.BRANCH}
                """
            }
        }
    }
}

Pipeline output shows SUCCESS, and when I check the server:

cd /var/www/html
git branch

I can switch between master and feature, and the files (index.html, feature.html) are present.

Despite this, the lab still returns “Validation file not found on App Server.”

Could someone please help confirm if I missed any requirement (job name, pipeline configuration, or deployment step)?

Thanks!

Please try referring to this solution in the thread, and see if it helps.

I’m still having the same issue

Did the agent actually get started and work? There’s a java version clash between the jenkins server and the App Server. Did you handle this?

Yes, the agent was able to start and run jobs successfully. Initially I had an issue starting the Jenkins agent because Java was not properly set up on the App Server (stapp01) . I installed OpenJDK 17 on the server and verified it with java -version . After that, Jenkins was able to launch the agent and run the pipeline without errors. I also fixed the permissions for /home/sarah/jenkins_agent and /var/www/html so the Jenkins user (tony ) could execute Git commands and deploy the code. After these fixes, the node connected successfully and the pipeline ran on App Server 1 (label: stapp01) , switching branches and deploying the code to /var/www/html .

I am exactly facing the same error “Validation file not found on App Server.”- tried like 5 times now - The conditional pipeline is working fine, builds are successful - and I can see through the LB UI, the text changing depending on the conditional pipeline I run.

@mmumshad and Team - can you please review this task?

Just tried the task, and this worked for me. Some questions for you:

  • What server was used as the node?
  • What does your pipeline script look like?

I followed this guide with modifications, because the node is now run as user sarah, and there was no need to use sudo in the script – everything runs as “sarah” and everything needed belongs to that user on the app server.

hi @desu95

There is a solution for this task.

This worked for me. Thanks, man! :smiley:

1 Like

Hello Rob, I followed the guide you mentioned. The task has been tweaked. “Add a slave node named App Server 1 . It should be labeled as stapp01 and its remote root directory should be /home/sarah/jenkins_agent (the repository is cloned under /var/www/html ).” I am running agent as stapp01 tony user using ssh but it failed as “Could not copy remoting.jar into ‘/home/sarah/jenkins_agent’ on agent”. Copying remoting.jar to sarah directory as a tony user will denied permission as clearly. How should I perform as a sarah?

It’s actually pretty simple, because the agent is running as user sarah, and all the directories you need read or write to belong to user sarah, or are readable by that user. So you don’t need to supply a password or do sudo to do anything in the job. That simplifies the task considerably.