I've been having some problems with a groovy script;
sh '''
echo \'Starting script\';
sleep 5;
echo \'pwd\';
sleep 5;
pwd;
sleep 5;
find / -name jenkins.war -type f;
sleep 5;
'''
Commands that take longer to execute always cause the pipeline to fail; all commands except find
are run successfully. In the logs (browser), a number of files are shown before the pipeline fails with message:
Jenkins build has status: FAILURE. Notifying Bitbucket with state: FAILED.
The issue is that there is no direct access to the jenkins server (no easy way to check logs).
I'm not sure if I'm going about this the right way but are there any settings that could cause such behavior?
There's a more elegant, more accurate and much more performant way to get Jenkins' version:
stages {
stage('Jenkins version') {
steps {
print "${Jenkins.getInstance().getVersion()}"
}
}
}
...
[Pipeline] stage
[Pipeline] { (Jenkins version)
[Pipeline] echo
2.303.2
...
Note: getInstance()
and getVersion()
have to be approved by a Jenkins admin.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.