0

My Issue : When I build using jenkins , I am getting error as No such file. But that file exists.

jenkins@ip-172-31-22-20:~/jobs$ ls -lthr /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml
-rw-r--r-- 1 jenkins jenkins 2.5K Mar 23 08:13 /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml
jenkins@ip-172-31-22-20:~/jobs$

My Error :

 cat: /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml: No such file or directory

My Post Build Action from Jenkins dashboard :

postsuccess()
{
  cat <<EOF
{  
    "state": "success",
    "target_url": "https://github.com/HSarode-Compumatrice/money-1",
    "description": "The build succeeded!",
    "context": "continuous-integration/jenkins"
}
EOF
}
postfailure()
{
  cat <<EOF
{  
    "state": "failure",
    "target_url": "https://github.com/HSarode-Compumatrice/money-1",
    "description": "Build Failure!",
    "context": "continuous-integration/jenkins"
}
EOF
}







echo "$BUILD_NUMBER"
BUILD_STATUS=`sudo cat /var/lib/jenkins/jobs/github-commit-status-api/builds/$BUILD_NUMBER/build.xml | grep -oP '(?<=<result>).*?(?=</result>)'`
echo $BUILD_STATUS 

if [ "$BUILD_STATUS" = "SUCCESS" ]
then
`curl -X POST -H "Authorization: Basic f69a042ad72594792950fecc8ca4539d2fff7b75" -H "Content-Type: application/json" 
-d  "$(postsuccess)" "https://api.github.com/repos/HSarode-Compumatrice/money-1/statuses/$GIT_COMMIT"` 
else
#`curl -X POST -H "Authorization: Basic f69a042ad72594792950fecc8ca4539d2fff7b75" -H "Content-Type: application/json" 
#-d  "$(postfailure)" "https://api.github.com/repos/HSarode-Compumatrice/money-1/statuses/$GIT_COMMIT"` 
echo "In Failed"
fi

Jenkins Console Output :

Started by user Harshal Sarode
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/lib/jenkins/workspace/github-commit-status-api
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/HSarode-Compumatrice/money-1.git # timeout=10
Fetching upstream changes from https://github.com/HSarode-Compumatrice/money-1.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://github.com/HSarode-Compumatrice/money-1.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b159d0e0d0f71f3d1e399c877705c9d698cd9e14 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f b159d0e0d0f71f3d1e399c877705c9d698cd9e14
 > git rev-list b159d0e0d0f71f3d1e399c877705c9d698cd9e14 # timeout=10
[github-commit-status-api] $ /bin/bash -xe /tmp/jenkins5873807540526862643.sh
+ echo 'Before Building!!'
Before Building!!
[PostBuildScript] - Execution post build scripts.
[github-commit-status-api] $ /bin/bash -xe /tmp/jenkins982148387285704643.sh
+ echo 43
43
++ sudo cat /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml
++ grep -oP '(?<=<result>).*?(?=</result>)'
cat: /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml: No such file or directory
+ BUILD_STATUS=
Build step 'Execute a set of scripts' changed build result to FAILURE
Build step 'Execute a set of scripts' marked build as failure
Finished: FAILURE
1

If you go into the /var/lib/jenkins/jobs/github-commit-status-api/builds/<build number> folder during a build, you'll see that build.xml doesn't exist and will not exist until after the build has completed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.