Skip to content

Add job to create ecr token for pipeline

Steve Xuereb requested to merge 27269-add-ci-job-for-token into master

What does this MR do?

Add a new job that will only run on the default branch and when a new release is tagged. This job will create an ECR token used to publish images.

Variables have been created inside of the Settings > CI/CD variables

Screen_Shot_2020-12-07_at_11.16.13

We can also see the dotenv variables working for both Windows and Linux in https://gitlab.com/steveazz/playground/-/pipelines/226162557

Why was this MR needed?

To create a temporary token for ECR public registry. This token can be used for both Windows and Linux environments to push images to the registry. Another merge request that will actually use the token will be created after this merge request.

What's the best way to test this MR?

  1. Fork https://gitlab.com/steveazz-playground/release-rules. This project has the same rule structure added in this merge request.

  2. Try to create a pipeline for the main branch. It will not run, because of the namespace check. Screen_Shot_2020-12-07_at_10.05.34

  3. Update the namespace check

    example patch
    diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
    index 28252a8..cd74738 100644
    --- a/.gitlab/ci/rules.gitlab-ci.yml
    +++ b/.gitlab/ci/rules.gitlab-ci.yml
    @@ -1,5 +1,5 @@
     .if-not-canonical-namespace: &if-not-canonical-namespace
    -  if: '$CI_PROJECT_NAMESPACE !~ /^steveazz-playground($|\/)/'
    +  if: '$CI_PROJECT_NAMESPACE !~ /^steveazz($|\/)/'
    
     .if-default-branch: &if-default-branch
       if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  4. Push change, now you should see a pipeline running for main https://gitlab.com/steveazz/release-rules/-/pipelines/226152355.

  5. Create test tags

    git tag -s malformed-tag -m "Version malformed-tag"
    git tag -s v1.0.0 -m "Version v1.0.0"
    git tag -s v1.0.0-rc1 -m "Version v1.0.0-rc1"
  6. Push tags: git push -u origin --tags

  7. Pipelines created only for v1.0.0 and v1.0.0-rc1 https://gitlab.com/steveazz/release-rules/-/pipelines

What are the relevant issue numbers?

reference #27269 (closed)

Edited by Steve Xuereb

Merge request reports