Skip to content

Commit 18c768b

Browse files
committed
added logs
1 parent 049dfb8 commit 18c768b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
INSERT INTO "plugin_parent_metadata" ("id", "name","identifier", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by")
2-
VALUES (nextval('id_seq_plugin_parent_metadata'), 'AWS ECR Retag','aws-retag','AWS ECR Retag plugin that enables retagging of container images within ECR','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/plugin-icons/ic-plugin-aws-ecr-retag.png','f', 'now()', 1, 'now()', 1);
2+
VALUES (nextval('id_seq_plugin_parent_metadata'), 'AWS ECR Retag','aws-retag-new','AWS ECR Retag plugin that enables retagging of container images within ECR','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/plugin-icons/ic-plugin-aws-ecr-retag.png','f', 'now()', 1, 'now()', 1);
33

44

55
INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest")
6-
VALUES (nextval('id_seq_plugin_metadata'), 'AWS ECR Retag','Re tag your ECR image with AWS ECR Retag','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='aws-retag'),'1.0.0', false, true);
6+
VALUES (nextval('id_seq_plugin_metadata'), 'AWS ECR Retag','Retag your ECR image with AWS ECR Retag','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='aws-retag-new'),'1.0.0', false, true);
77

88
INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by")
99
VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='AWS ECR Retag' and deleted= false),0,'now()', 1, 'now()', 1);
@@ -14,34 +14,39 @@ INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_o
1414
#!/bin/sh
1515
set -eo pipefail
1616
#set -v ## uncomment this to debug the script
17-
AwsAccessKey="${AccessKey:-$(echo "$CI_CD_EVENT" | jq -r \'.commonWorkflowRequest.accessKey\')}"
18-
AwsSecretKey="${SecretKey:-$(echo "$CI_CD_EVENT" | jq -r \'.commonWorkflowRequest.secretKey\')}"
17+
AwsAccessKey="${AwsAccessEcrKey:-$(echo "$CI_CD_EVENT" | jq -r \'.commonWorkflowRequest.accessKey\')}"
18+
AwsSecretKey="${AwsSecretEcrKey:-$(echo "$CI_CD_EVENT" | jq -r \'.commonWorkflowRequest.secretKey\')}"
1919
mkdir -p ~/.aws
2020
echo -e "\n[tag-profile]\naws_access_key_id = $AwsAccessKey\naws_secret_access_key =$AwsSecretKey" >> ~/.aws/credentials
2121
if [[ $AwsAccessKey ]]; then
2222
export AWS_PROFILE=tag-profile
2323
fi
2424
pipeline_type=$(echo $CI_CD_EVENT | jq -r \'.type\')
2525
Region=$(echo $CI_CD_EVENT | jq -r .commonWorkflowRequest.dockerRegistryURL | sed \'s|https://||\'| awk -F. \'{print $4}\')
26+
echo "************* Starting the AWS ECR Retag plugin *******************"
2627
if [[ "$pipeline_type" == "CI" ]]; then
2728
image_repo=$(echo $CI_CD_EVENT | jq -r .commonWorkflowRequest.dockerRepository)
2829
image_tag=$(echo $CI_CD_EVENT | jq -r .commonWorkflowRequest.dockerImageTag)
2930
MANIFEST=$(aws ecr batch-get-image --repository-name $image_repo --image-ids imageTag=$image_tag --region $Region --output text --query \'images[].imageManifest\')
30-
aws ecr put-image --repository-name $image_repo --image-tag=$CustomTag --image-manifest "$MANIFEST" --region $Region
31+
aws ecr put-image --repository-name $image_repo --image-tag=$AwsEcrCustomTag --image-manifest "$MANIFEST" --region $Region
3132
elif [[ "$pipeline_type" == "CD" ]]; then
3233
image_repo=$(echo $CI_CD_EVENT | jq -r .commonWorkflowRequest.ciArtifactDTO.image | cut -d\'/\' -f2 | cut -d\':\' -f1)
3334
image_tag=$(echo $CI_CD_EVENT | jq -r .commonWorkflowRequest.ciArtifactDTO.image | cut -d \':\' -f2)
3435
MANIFEST=$(aws ecr batch-get-image --repository-name $image_repo --image-ids imageTag=$image_tag --region $Region --output text --query \'images[].imageManifest\')
35-
aws ecr put-image --repository-name $image_repo --image-tag=$CustomTag --image-manifest "$MANIFEST" --region $Region
36+
aws ecr put-image --repository-name $image_repo --image-tag=$AwsEcrCustomTag --image-manifest "$MANIFEST" --region $Region
37+
fi
38+
if [ $? -ne 0 ]; then
39+
echo "*************Failed to Retag the image****************"
3640
else
37-
echo "No able to re-tag the image"
38-
fi ' ,'SHELL','f','now()',1,'now()',1);
41+
echo "*************Image Retag is done sucessfully*********************"
42+
fi
43+
' ,'SHELL','f','now()',1,'now()',1);
3944

4045

4146
INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by")
4247
VALUES (nextval('id_seq_plugin_step'), (SELECT id FROM plugin_metadata WHERE name='AWS ECR Retag' AND plugin_version='1.0.0' AND deleted= false),'Step 1','Runnig the plugin','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1);
4348

4449
INSERT INTO plugin_step_variable (id,plugin_step_id,name,format,description,is_exposed,allow_empty_value,default_value,value,variable_type,value_type,previous_step_index,variable_step_index,variable_step_index_in_plugin,reference_variable_name,deleted,created_on,created_by,updated_on,updated_by)
45-
VALUES (nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'CustomTag','STRING','Provide the tag for retagging','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
46-
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'AccessKey','STRING','Provide the access key','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
47-
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'SecretKey','STRING','Provide the secret key','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1);
50+
VALUES (nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'AwsEcrCustomTag','STRING','Provide the tag for retagging','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
51+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'AwsAccessEcrKey','STRING','Provide the access key with ECR permission','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
52+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='AWS ECR Retag' and p.plugin_version='1.0.0' and ps."index"=1 and ps.deleted=false),'AwsSecretEcrKey','STRING','Provide the secret key with ECR permission','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1);

0 commit comments

Comments
 (0)