<aside> ⚠️ If you can use the GitHub/GitLab Application, we highly recommend going that route, see Install GitHub/GitLab App . However, if you have a multi-repository setup, or have a different CI/CD pipeline, you can observe the run results directly.
</aside>
import { makeQaWolfSdk } from "@qawolf/ci-sdk";
const { pollCiGreenlightStatus } = makeQaWolfSdk({
apiKey: "qawolf_xxxxx",
});
(async () => {
// Retrieve runId from the previous job.
const { outcome } = await pollCiGreenlightStatus({
runId,
// Optional: Callback to be called when the run stage changes.
onRunStageChanged: (current, previous) => {
console.log(current, previous);
},
// Optional: abort the job when a superseding run is encountered.
// Default "false"
abortOnSuperseded: false,
// EXPERIMENTAL!
// Optional: Defaults to "green".
// When set to `"red"`, the job will fail when blocking bugs were
// found in the environment that were affecting workflows not executed
// in the run.
outcomeWhenBlockingBugsInOtherWorkflows: "green",
});
if (outcome !== "success") {
// Fail the job.
// This will depend on the CI platform you are using.
// You can also distinguish between "failed" and "aborted" outcomes.
// Only "failed" outcome indicates bugs were found.
process.exit(1);
}
// Continue CI.
})();
<aside>
ℹ️ You can inspect the outcome.ciGreenlightStatus
object when the outcome is "success"
. It will provide ample details on the results of the run. See 200 Response (CI Greenlight status).
</aside>
See @qawolf/ci-sdk
for more details.
If you don’t want/cannot use the JavaScript SDK, you can integrate with the CI Greenlight HTTP endpoint directly.