Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function detectURL(options) {
// Figure out the appropriate index namespace.
let nsparts = ['buildbot', 'branches', options.branch];
let buildname = buildinfo.buildname(options);
nsparts.push(buildname);
let ns = nsparts.join('.');
// Find task in namespace.
let index = new taskcluster.Index(TC_CLIENT_OPTS);
let task = await index.findTask(ns);
// List task artifacts.
let queue = new taskcluster.Queue(TC_CLIENT_OPTS);
let { artifacts } = await queue.listLatestArtifacts(task.taskId);
// Default to downloading the build archive for our os.
let os = options.os;
let product = options.product;
let suffix = !!options.fileSuffix ?
options.fileSuffix :
buildinfo.archiveFileSuffix(product, os);
// Filter through namespace artifacts.
let artifact = artifacts.find(art => art.name.indexOf(suffix) !== -1);
if (!artifact) {
workerType: 'succeed',
created: (new Date()).toJSON(),
deadline: taskcluster.fromNowJSON('2 minutes'),
expires: taskcluster.fromNowJSON('60 minutes'),
metadata: {
name: "Smoketest indexTask-find",
description: "built-in/succeed task created during smoketest",
owner: "smoketest@taskcluster.net",
source: "https://taskcluster.net",
},
payload: {},
routes: [`index.${taskIndex}`],
};
utils.status({ message: 'indexTask-find taskId: ' + randomId });
await queue.createTask(randomId, task);
let index = new taskcluster.Index(taskcluster.fromEnvVars());
let pollForStatusStart = new Date();
while ((new Date() - pollForStatusStart) < 120000) {
let status = await queue.status(randomId);
if (status.status.state === 'pending' || status.status.state === 'running') {
utils.status({
message: 'Current task status: ' + status.status.state,
});
} else if (status.status.state === 'completed') {
try {
await index.findTask(taskIndex);
return;
}
catch (err) {
utils.status({
message: 'waiting for the task to be indexed',
});
async function findTaskWithImageArtifact(ns) {
let index = new taskcluster.Index(taskcluster.fromEnvVars());
let {taskId} = await index.findTask(ns);
let has_image = await taskHasImageArtifact(taskId);
return has_image ? taskId : null;
}
module.exports = options => ({
auth: new Auth(options),
github: new Github(options),
hooks: new Hooks(options),
index: new Index(options),
purgeCache: new PurgeCache(options),
queue: new Queue(options),
secrets: new Secrets(options),
queueEvents: new QueueEvents(options),
notify: new Notify(options),
workerManager: new WorkerManager(options),
});
async function findTaskWithImageArtifact(ns) {
let index = new taskcluster.Index();
let {taskId} = await index.findTask(ns);
let has_image = await taskHasImageArtifact(taskId);
return has_image ? taskId : null;
}
function asyncFindTaskWithImageArtifact(ns) {
var index = new taskcluster.Index();
return index.findTask(ns).then(function (result) {
return asyncTaskHasImageArtifact(result.taskId).then(function (has_image) {
return has_image ? result.taskId : null;
});
}, function () {
return null;
});
}