@docupace/pipeline 1.0.1-2.ervinsUpdate2.6 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,115 +0,0 @@
1
- import axios from 'axios';
2
- import { getBitbucketInfo } from './config.js';
3
-
4
- const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
5
-
6
- const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
7
-
8
- async function triggerPipelineByName(
9
- repository,
10
- pipelineName,
11
- branch,
12
- variables,
13
- ) {
14
- const { username, password, workspace } = getBitbucketInfo();
15
- const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/`;
16
- const auth = {
17
- username: username,
18
- password: password,
19
- };
20
-
21
- const payload = {
22
- target: {
23
- type: 'pipeline_ref_target',
24
- ref_type: 'branch',
25
- ref_name: branch,
26
- selector: {
27
- type: 'custom',
28
- pattern: pipelineName,
29
- },
30
- },
31
- variables: variables
32
- ? Object.entries(variables).map(([key, value]) => ({
33
- key,
34
- value,
35
- secured: false, // Set to true if the variable should be secure
36
- }))
37
- : undefined,
38
- };
39
-
40
- try {
41
- const response = await axios.post(url, payload, { auth });
42
- return response.data;
43
- } catch (error) {
44
- console.error(
45
- 'Error triggering custom pipeline:',
46
- error.response?.data || error.message,
47
- );
48
- throw error;
49
- }
50
- }
51
-
52
- async function getPipelineStatus(repository, pipelineUUID) {
53
- const { username, password, workspace } = getBitbucketInfo();
54
- const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/${pipelineUUID}`;
55
- const auth = {
56
- username: username,
57
- password: password,
58
- };
59
-
60
- try {
61
- const response = await axios.get(url, { auth });
62
- return response.data.state.name;
63
- } catch (error) {
64
- console.error(
65
- 'Error fetching pipeline status:',
66
- error.response?.data || error.message,
67
- );
68
- throw error;
69
- }
70
- }
71
-
72
- export async function runPipeline(
73
- repository,
74
- pipelineName,
75
- branch,
76
- variables,
77
- wait = false,
78
- ) {
79
- try {
80
- console.log(
81
- `Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
82
- );
83
- const pipeline = await triggerPipelineByName(
84
- repository,
85
- pipelineName,
86
- branch,
87
- variables,
88
- );
89
-
90
- const pipelineUUID = pipeline.uuid;
91
- const buildNumber = pipeline.build_number;
92
-
93
- console.log(`Pipeline triggered with UUID: ${pipelineUUID}`);
94
- console.log(
95
- `See results here: ${BITBUCKET_WS_URL}/${repository}/piplines/results/${buildNumber}`,
96
- );
97
-
98
- if (!wait) {
99
- return;
100
- }
101
-
102
-
103
- let status = '';
104
- do {
105
- console.log('Checking pipeline status...');
106
- await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
107
- status = await getPipelineStatus(repository, pipelineUUID);
108
- console.log(`Pipeline status: ${status}`);
109
- } while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
110
-
111
- console.log(`Pipeline completed with status: ${status}`);
112
- } catch (error) {
113
- console.error('Error monitoring pipeline:', error.message);
114
- }
115
- }
package/src/next/vault.js DELETED
@@ -1,39 +0,0 @@
1
- import axios from 'axios';
2
-
3
- export async function vaultAddSiteData(SITE) {
4
- const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID;
5
- const AUTH0_CLIENT_SECRET = process.env.AUTH0_CLIENT_SECRET;
6
- const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
7
- const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
8
-
9
- if (!VAULT_ADDR || !VAULT_TOKEN) {
10
- throw new Error('Missing VAULT_ADDR or VAULT_TOKEN environment variable.');
11
- }
12
-
13
- const vaultApiUrl = `${VAULT_ADDR}/v1/secret/data/${SITE}/common/config`;
14
-
15
- try {
16
- const response = await axios.post(
17
- vaultApiUrl,
18
- {
19
- data: {
20
- AUTH0_CLIENT_ID: AUTH0_CLIENT_ID,
21
- AUTH0_CLIENT_SECRET: AUTH0_CLIENT_SECRET,
22
- },
23
- },
24
- {
25
- headers: {
26
- 'X-Vault-Token': VAULT_TOKEN,
27
- 'Content-Type': 'application/json',
28
- },
29
- }
30
- );
31
-
32
- console.log('Data added to Vault successfully:', response.data);
33
- } catch (error) {
34
- console.error('Error adding data to Vault:', error.response?.data || error.message);
35
- throw error;
36
- }
37
- }
38
-
39
-
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- PROJECT=$1
5
-
6
- if [[ -z "$PROJECT" ]]; then
7
- echo "Error: Project name is required."
8
- echo "Usage: $0 <project-name>"
9
- exit 1
10
- fi
11
-
12
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
13
- export SESSION_NAME="EKSAdminSession"
14
- export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
15
- export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
16
- export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
17
- export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
18
- export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
19
- export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
20
- export TF_IN_AUTOMATION=1
21
-
22
- aws sts get-caller-identity
23
-
24
- cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
25
-
26
- terraform apply -input=false .tfplan
package/terraform/init.sh DELETED
@@ -1,36 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- PROJECT=$1
5
- CURRENT_ENVIRONMENT=$2
6
-
7
- if [[ -z "$PROJECT" ]]; then
8
- echo "Error: Project name is required."
9
- echo "Usage: $0 <project-name> $1 <environment>"
10
- exit 1
11
- fi
12
-
13
- if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
14
- echo "Error: ENVIRONMENT is required."
15
- echo "Usage: $0 <project-name> $1 <environment>"
16
- exit 1
17
- fi
18
-
19
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
20
- export SESSION_NAME="EKSAdminSession"
21
- export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
22
- export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
23
- export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
24
- export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
25
- export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
26
- export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
27
-
28
- aws sts get-caller-identity
29
- cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
30
- mkdir -p ~/.ssh
31
-
32
- echo "$atlassian_workspace_runner_ssh_key" | base64 -d > ~/.ssh/id_ed25519
33
- chmod 600 ~/.ssh/id_ed25519
34
- ssh-keyscan bitbucket.org > ~/.ssh/known_hosts
35
-
36
- terraform init -backend-config=./env/${CURRENT_ENVIRONMENT}/us-west-2/backend.tfvars --reconfigure
package/terraform/plan.sh DELETED
@@ -1,44 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- PROJECT=$1
5
- CURRENT_ENVIRONMENT=$2
6
-
7
- if [[ -z "$PROJECT" ]]; then
8
- echo "Error: Project name is required."
9
- echo "Usage: $0 <project-name> $1 <environment>"
10
- exit 1
11
- fi
12
-
13
- if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
14
- echo "Error: ENVIRONMENT is required."
15
- echo "Usage: $0 <project-name> $1 <environment>"
16
- exit 1
17
- fi
18
-
19
- export ROLE_NAME="atlassian-bitbucket-pipelines-runner-eks-role"
20
- export SESSION_NAME="EKSAdminSession"
21
- export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
22
- export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
23
- export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
24
- export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
25
- export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
26
- export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
27
-
28
- aws sts get-caller-identity
29
-
30
- cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
31
-
32
- if [[ "$PROJECT" == "bb-build-agent-shell" ]]; then
33
- if [[ "$CURRENT_ENVIRONMENT" == "dev" ]]; then
34
- echo "$dev_build_agent_configuration" | base64 -d > ./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json
35
- elif [[ "$CURRENT_ENVIRONMENT" == "qa" ]]; then
36
- echo "$qa_build_agent_configuration" | base64 -d > ./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json
37
- fi
38
-
39
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" \
40
- -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json" \
41
- -out .tfplan
42
- else
43
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" -out .tfplan
44
- fi
@@ -1,17 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- PROJECT=$1
5
-
6
- if [[ -z "$PROJECT" ]]; then
7
- echo "Error: Project name is required."
8
- echo "Usage: $0 <project-name>"
9
- exit 1
10
- fi
11
-
12
- cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
13
-
14
- terraform version
15
- terraform init -backend=false
16
- terraform validate
17
- terraform fmt -check -recursive --diff