Edits history of script submission #1496 for ' Update a build status for a commit (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a build status for a commit
     * Used to update the current status of a build status object on the
    specific commit.
    
    This operation can also be used to change other properties of the
    build status:
    
    * `state`
    * `name`
    * `description`
    * `url`
    * `refname`
    
    The `key` cannot be changed.
     */
    export async function main(
      auth: Bitbucket,
      commit: string,
      key: string,
      repo_slug: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          self?: { href?: string; name?: string };
          commit?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        refname?: string;
        url?: string;
        state?: "FAILED" | "INPROGRESS" | "STOPPED" | "SUCCESSFUL";
        name?: string;
        description?: string;
        created_on?: string;
        updated_on?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a build status for a commit
     * Used to update the current status of a build status object on the
    specific commit.
    
    This operation can also be used to change other properties of the
    build status:
    
    * `state`
    * `name`
    * `description`
    * `url`
    * `refname`
    
    The `key` cannot be changed.
     */
    export async function main(
      auth: Bitbucket,
      commit: string,
      key: string,
      repo_slug: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          self?: { href?: string; name?: string };
          commit?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        refname?: string;
        url?: string;
        state?: "FAILED" | "INPROGRESS" | "STOPPED" | "SUCCESSFUL";
        name?: string;
        description?: string;
        created_on?: string;
        updated_on?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 802 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a build status for a commit
     * Used to update the current status of a build status object on the
    specific commit.
    
    This operation can also be used to change other properties of the
    build status:
    
    * `state`
    * `name`
    * `description`
    * `url`
    * `refname`
    
    The `key` cannot be changed.
     */
    export async function main(
      auth: Bitbucket,
      commit: string,
      key: string,
      repo_slug: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          self?: { href?: string; name?: string };
          commit?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        refname?: string;
        url?: string;
        state?: "STOPPED" | "FAILED" | "INPROGRESS" | "SUCCESSFUL";
        name?: string;
        description?: string;
        created_on?: string;
        updated_on?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 880 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a build status for a commit
     * Used to update the current status of a build status object on the
    specific commit.
    
    This operation can also be used to change other properties of the
    build status:
    
    * `state`
    * `name`
    * `description`
    * `url`
    * `refname`
    
    The `key` cannot be changed.
     */
    export async function main(
      auth: Bitbucket,
      commit: string,
      key: string,
      repo_slug: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          self?: { href?: string; name?: string };
          commit?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        refname?: string;
        url?: string;
        state?: "INPROGRESS" | "FAILED" | "SUCCESSFUL" | "STOPPED";
        name?: string;
        description?: string;
        created_on?: string;
        updated_on?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 929 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a build status for a commit
     * Used to update the current status of a build status object on the
    specific commit.
    
    This operation can also be used to change other properties of the
    build status:
    
    * `state`
    * `name`
    * `description`
    * `url`
    * `refname`
    
    The `key` cannot be changed.
     */
    export async function main(
      auth: Bitbucket,
      commit: string,
      key: string,
      repo_slug: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          self?: { href?: string; name?: string };
          commit?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        refname?: string;
        url?: string;
        state?: "STOPPED" | "INPROGRESS" | "SUCCESSFUL" | "FAILED";
        name?: string;
        description?: string;
        created_on?: string;
        updated_on?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago