jfrog / setup-jfrog-cli

Set up JFrog CLI in your GitHub Actions workflow
Apache License 2.0
241 stars 73 forks source link

Using GITHUB_RUN_NUMBER Environment Variable Instead of Commit Hash #10

Closed talitz closed 3 years ago

talitz commented 4 years ago

Hi,

I would like to suggest using the ${GITHUB_RUN_NUMBER} environment variable instead of the commit hash as the build number published to JFrog Artifactory.

From it's description it sounds like it might fit better:

"A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run."

Hope my feedback helps!

Tal

jvalkeal commented 3 years ago

I'd also change JFROG_CLI_BUILD_URL as it points to https://github.com/:owner/:repo/commit/:sha/checks which is not so good if you do builds from a same commit. JFROG_CLI_BUILD_NAME is also something you always want to change. For now you need to tweak these together with doing an actual cli build config.

    - uses: jfrog/setup-jfrog-cli@v1
      with:
        version: 1.43.2
    - name: Configure JFrog Cli
      run: |
        jfrog rt gradlec \
          --server-id-resolve=local \
          --server-id-deploy=local \
          --repo-resolve=libs-snapshot \
          --repo-deploy=libs-snapshot \
          --use-wrapper=true
        echo JFROG_CLI_BUILD_NAME=test-build-project >> $GITHUB_ENV
        echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
        echo JFROG_CLI_BUILD_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID >> $GITHUB_ENV

Would very much like to see a way to customise these directly with cli action config.

yahavi commented 3 years ago

@talitz @jvalkeal Setup JFrog CLI 1.2.0 is released and synchronized with the v1 tag. This version includes your suggestions. We'd appreciate your feedback on that.

craustin commented 3 years ago

@yahavi The build number and url changes look good. The build name though is still set to the workflow name, which I don't think should be expected to match the package name. Is there a better way to infer the build name here: https://github.com/jfrog/setup-jfrog-cli/blob/master/src/utils.ts#L54 ?

@talitz above has it hardcoded: https://github.com/jfrog/setup-jfrog-cli/issues/10#issuecomment-764503111

yahavi commented 3 years ago

@craustin Thanks for your feedback. The package name heavily depends on the technology you use to build your project. You don't even have to create a package in your build, for example, think about a build that only runs an Xray scan. On the other hand, there may be builds that create multiple packages. It's hard to guess the user's intention.

Therefore we think that the workflow's name is the best option to represent the build name. You also have the option to override the JFROG_CLI_BUILD_NAME environment variable to your requested build name.

Please let us know if you have any thoughts/ideas.