我的问题:当我使用 jenkins 构建时,我收到没有这样的文件的错误。但是那个文件是存在的。
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$
我的错误:
cat: /var/lib/jenkins/jobs/github-commit-status-api/builds/43/build.xml: No such file or directory
我来自 Jenkins 仪表板的构建后操作:
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
詹金斯控制台输出:
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
/var/lib/jenkins/jobs/github-commit-status-api/builds/<build number>
如果您在构建过程中进入该文件夹,您会看到该文件夹build.xml
不存在,并且在构建完成之前不会存在。