Edits history of script submission #1575 for ' Get log file for a step (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Get log file for a step
     * Retrieve the log file for a given step of a pipeline.
    
    This endpoint supports (and encourages!) the use of [HTTP Range requests](https://tools.ietf.org/html/rfc7233) to deal with potentially very large log files.
     */
    export async function main(
      auth: Bitbucket,
      workspace: string,
      repo_slug: string,
      pipeline_uuid: string,
      step_uuid: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines/${pipeline_uuid}/steps/${step_uuid}/log`
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Get log file for a step
     * Retrieve the log file for a given step of a pipeline.
    
    This endpoint supports (and encourages!) the use of [HTTP Range requests](https://tools.ietf.org/html/rfc7233) to deal with potentially very large log files.
     */
    export async function main(
      auth: Bitbucket,
      workspace: string,
      repo_slug: string,
      pipeline_uuid: string,
      step_uuid: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines/${pipeline_uuid}/steps/${step_uuid}/log`
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 935 days ago