Check Jenkins job status after triggering a build remotely

前端 未结 4 828
夕颜
夕颜 2020-12-10 02:39

I have a script to trigger a job on Jenkins remotely using a token. Here is my script:

JENKINS_URL=\'http://jenkins.myserver.com/jenkins\'
JOB_NAME=\'job/uti         


        
4条回答
  •  独厮守ぢ
    2020-12-10 03:07

    When you trigger a job, the job is placed into the queue. The actual build is created only when it starts running and at that point the build gets a build number. If all your executors are busy, it can sometimes take a long time before the build is created and starts running.

    The only way to get the build number when triggering a job, is to use the "build" command of the Jenkins CLI. If you use the -w option, the command will not return until the build starts and then it will print "Started build #N"

    You do not actually need the java cli.jar, just an ssh client is enough. See https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+SSH

    Other than that there is no known solution. You might be able to search through the builds and find a one that was triggered around the time your triggered the job, but that's a lot of work.

提交回复
热议问题