Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job build returns queue id but queue is empty #105

Open
rikiNeustadt opened this issue Dec 16, 2021 · 1 comment
Open

job build returns queue id but queue is empty #105

rikiNeustadt opened this issue Dec 16, 2021 · 1 comment

Comments

@rikiNeustadt
Copy link

rikiNeustadt commented Dec 16, 2021

I tried to use @silas solution on this issue: #102.
I get an error of 'Error: jenkins: queue.item: not found.'
After building the job I get the queue ID but, somehow the queue is broken.
Please help

async function main() {
  const queueId = await jenkins.job.build({
        name: jobName,
        parameters: {
            user: username,
        }
    });
  console.log(queueId); //30960
  let queueItem;
  while (true) {
    queueItem = await jenkins.queue.item(queueId); //Error: jenkins: queue.item: not found

    if (queueItem.executable) {
      break;
    }

    if (queueItem.cancelled) {
      console.log('queue cancelled');
      return;
    }

    console.log('waiting on queue...');
    await new Promise(r => setTimeout(r, 1000));
  }

  let job;
  while (true) {
    job = await jenkins.build.get(jobName, queueItem.executable.number);

    if (!job.building) {
      break;
    }

    console.log('waiting on job...');
    await new Promise(r => setTimeout(r, 1000));
  }

  console.log(job.fullDisplayName, job.result);
}

main();

@silas
Copy link
Owner

silas commented Dec 17, 2021

It's possible you have to handle a 404 from the queue endpoint and retry with some max retry timeout (I've seen issues that report that the queue is guaranteed to live for at least 5 minutes, so you could use that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants