conan-io / conan-package-tools

Conan Package Tools. Helps with massive package creation and CI integration (Travis CI, Appveyor...)
MIT License
165 stars 70 forks source link

GitLab CI stable/testing branch pattern detection with master/develop branches #599

Closed SteRoh closed 2 years ago

SteRoh commented 2 years ago

Description of Problem, Request, or Question

I'm trying to use CPT from a Giltab CI pipeline where Conan packages are uploaded to an Artifactory instance. There is one master branch and multiple develop branches. Each tag shall upload my package either to stable (tag on master branch) or testing (tag on other branches).

My assumption was to use the stable_branch_pattern, but this does not belong to $CI_BUILD_REF_NAME. If I tag on master branch CPT detects only the tag:

 >> Branch detected
   >> 1.10.0

Obviously this tag does not match the pattern.

Steps to reproduce (Include if Applicable)

My expected GitLab stage:

.deploy:
  only:
    - tags 
  variables:
    CONAN_USERNAME: "user"
    CONAN_STABLE_BRANCH_PATTERN: "master$ main$ release.* stable.*" # all tags on master branch will be deployed to "stable" channel (all others: "testing")
  script:
    - python3 build.py

My CPT output if i tag on master

[local_vars]
+---------------------------+------------------------------------------------------------------+
| Configuration             | value                                                            |
|---------------------------+------------------------------------------------------------------|
| username                  | user|
| upload_only_when_stable   | False                                                            |
| upload_only_when_tag      | False                                                            |
| stable_branch_pattern     | master$ main$ release.* stable.*                                 |
| stable_channel            | stable                                                           |
| channel                   | testing                                                          |

Is there an easy way to use the gitlab only: -tagsfeature with stable/testing detection? My current solution always uploads to testing, due to misleading branch detection.

Environment Details

SteRoh commented 2 years ago

I think you can close this issue, my understanding of git + tags was a little bit confusing.

A tag is not related to a branch but we create our packages for each tag commit. Now I´m solving my problem with a tag convention.

  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
      variables:                              
        CONAN_CHANNEL: "stable"
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^(\d+\.\d+\.\d*-rc.+$)/'
      variables:                              
        CONAN_CHANNEL: "testing"    

Maybe this helps other people which are a bit slow on the uptake :)