Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53535

Make Bitbucket Server, Owner and repository environment variables for Bitbucket Team/Project based jobs

    • 933.1.0

      Similar to the BRANCH_NAME variable, it would be nice to expose the REPOSITORY_NAME and the PROJECT_NAME as environment variables.

          [JENKINS-53535] Make Bitbucket Server, Owner and repository environment variables for Bitbucket Team/Project based jobs

          Nikolas Falco added a comment -

          Hi markewaite , I have a question for you.
          This is not the first request of this kind that I have received from users. I have read the environment variables that git-plugin makes available and I was wondering if there was a specific reason why the repository name is not among them.
          Currently some users are analyzing the URL used in the git clone to get this value.

          The repository is useful when in the pipeline you have to perform some curl to the Bitbucket API (I suppose the same could be for github)

          Nikolas Falco added a comment - Hi markewaite , I have a question for you. This is not the first request of this kind that I have received from users. I have read the environment variables that git-plugin makes available and I was wondering if there was a specific reason why the repository name is not among them. Currently some users are analyzing the URL used in the git clone to get this value. The repository is useful when in the pipeline you have to perform some curl to the Bitbucket API (I suppose the same could be for github)

          Mark Waite added a comment -

          nfalco asked:

          This is not the first request of this kind that I have received from users. I have read the environment variables that git-plugin makes available and I was wondering if there was a specific reason why the repository name is not among them.
          Currently some users are analyzing the URL used in the git clone to get this value.

          I am not sure that there is a clear meaning for repository name. Can you help me understand the repository name for the following cases:

          git@github.com:MarkEWaite/bin.git
          https://markewaite@bitbucket.org/git-client-plugin.git
          https://git.assembla.com/git-plugin.3.git
          git@git.assembla.com:git-plugin.3.git
          git@bitbucket.org:markewaite/jenkins-pipeline-utils.git
          https://markewaite@bitbucket.org/markewaite/jenkins-pipeline-utils.git
          mwaite@git.markwaite.net:git/bare/jenkins/git-client-plugin.git
          https://gitea.com/Mark-Waite/git-client-plugin.git
          git@gitea.com:Mark-Waite/git-client-plugin.git
          git@gitlab.com:MarkEWaite/bin.git
          https://gitlab.com/MarkEWaite/bin.git
          markwaite@vs-ssh.visualstudio.com:v3/markwaite/elisp/elisp
          https://markwaite.visualstudio.com/DefaultCollection/elisp/_git/elisp
          

          Mark Waite added a comment - nfalco asked: This is not the first request of this kind that I have received from users. I have read the environment variables that git-plugin makes available and I was wondering if there was a specific reason why the repository name is not among them. Currently some users are analyzing the URL used in the git clone to get this value. I am not sure that there is a clear meaning for repository name. Can you help me understand the repository name for the following cases: git@github.com:MarkEWaite/bin.git https: //markewaite@bitbucket.org/git-client-plugin.git https: //git.assembla.com/git-plugin.3.git git@git.assembla.com:git-plugin.3.git git@bitbucket.org:markewaite/jenkins-pipeline-utils.git https: //markewaite@bitbucket.org/markewaite/jenkins-pipeline-utils.git mwaite@git.markwaite.net:git/bare/jenkins/git-client-plugin.git https: //gitea.com/Mark-Waite/git-client-plugin.git git@gitea.com:Mark-Waite/git-client-plugin.git git@gitlab.com:MarkEWaite/bin.git https: //gitlab.com/MarkEWaite/bin.git markwaite@vs-ssh.visualstudio.com:v3/markwaite/elisp/elisp https: //markwaite.visualstudio.com/DefaultCollection/elisp/_git/elisp

          Nikolas Falco added a comment - - edited

          Hi markewaite, sorry for late response I did not get the email notification.

          Any git server have the repository name just because otherwise you can not have different bucket where put diffent code. Anyway I expect is not something that must be extracted from URL but something that implementation of SCMHead.getRepositoryName() must provide.

          For what I know about server I used:

          git@github.com:MarkEWaite/bin.git

          repository name: bin

          https://markewaite@bitbucket.org/git-client-plugin.git
          

          repository name: git-client-plugin

          git@bitbucket.org:markewaite/jenkins-pipeline-utils.git
          

          repository name: jenkins-pipeline-utils

          https://markewaite@bitbucket.org/markewaite/jenkins-pipeline-utils.git
          mwaite@git.markwaite.net:git/bare/jenkins/git-client-plugin.git
          

          repository name: git-client-plugin

          https://gitea.com/Mark-Waite/git-client-plugin.git
          git@gitea.com:Mark-Waite/git-client-plugin.git
          

          repository name: git-client-plugin

          git@gitlab.com:MarkEWaite/bin.git
          https://gitlab.com/MarkEWaite/bin.git
          

          repository name: bin

          markwaite@vs-ssh.visualstudio.com:v3/markwaite/elisp/elisp
          https://markwaite.visualstudio.com/DefaultCollection/elisp/_git/elisp
          

          azure repository name: elisp

          git server unknow to me

          https://git.assembla.com/git-plugin.3.git
          git@git.assembla.com:git-plugin.3.git
          

          I was asking just because I would avoid to provide a new env variable named like GIT_REPOSITORY_NAME or BITBUCKET_REPOSITORY and than, maybe after 1 year, the git-plugin provides a NEW env variable with the same goal, so, I have to deprecated that one provided by the bitbucket plugin in favour of that one provided by the git-plugin and then, after a while remove it (I already expect lot of bug for this last action).

          So if you've considered exposing the repository name but have discarded it, then the bitbucket plugin will contributes to the environment variables with repository name (repo_slug in atlassian terms).
          If you've never considered the idea, maybe this is a good opportunity and I'll hold off on the task while I wait for the SCMHead method to be implemented.

          PS: Trust me, you have too many repositories, it seems you take the disaster and recovery too seriously

          Nikolas Falco added a comment - - edited Hi markewaite , sorry for late response I did not get the email notification. Any git server have the repository name just because otherwise you can not have different bucket where put diffent code. Anyway I expect is not something that must be extracted from URL but something that implementation of SCMHead.getRepositoryName() must provide. For what I know about server I used: git@github.com:MarkEWaite/bin.git repository name: bin https://markewaite@bitbucket.org/git-client-plugin.git repository name: git-client-plugin git@bitbucket.org:markewaite/jenkins-pipeline-utils.git repository name: jenkins-pipeline-utils https://markewaite@bitbucket.org/markewaite/jenkins-pipeline-utils.git mwaite@git.markwaite.net:git/bare/jenkins/git-client-plugin.git repository name: git-client-plugin https://gitea.com/Mark-Waite/git-client-plugin.git git@gitea.com:Mark-Waite/git-client-plugin.git repository name: git-client-plugin git@gitlab.com:MarkEWaite/bin.git https://gitlab.com/MarkEWaite/bin.git repository name: bin markwaite@vs-ssh.visualstudio.com:v3/markwaite/elisp/elisp https://markwaite.visualstudio.com/DefaultCollection/elisp/_git/elisp azure repository name: elisp git server unknow to me https://git.assembla.com/git-plugin.3.git git@git.assembla.com:git-plugin.3.git I was asking just because I would avoid to provide a new env variable named like GIT_REPOSITORY_NAME or BITBUCKET_REPOSITORY and than, maybe after 1 year, the git-plugin provides a NEW env variable with the same goal, so, I have to deprecated that one provided by the bitbucket plugin in favour of that one provided by the git-plugin and then, after a while remove it (I already expect lot of bug for this last action). So if you've considered exposing the repository name but have discarded it, then the bitbucket plugin will contributes to the environment variables with repository name (repo_slug in atlassian terms). If you've never considered the idea, maybe this is a good opportunity and I'll hold off on the task while I wait for the SCMHead method to be implemented. PS: Trust me, you have too many repositories, it seems you take the disaster and recovery too seriously

          Mark Waite added a comment - - edited

          So if you've considered exposing the repository name but have discarded it, then the bitbucket plugin will contributes to the environment variables with repository name (repo_slug in atlassian terms).
          If you've never considered the idea, maybe this is a good opportunity and I'll hold off on the task while I wait for the SCMHead method to be implemented.

          I've never considered the idea. I don't see enough benefit to adding more parsed segments of the repository URL, so I'm unlikely to add it to the git plugin or the git client plugin.

          No objection from me if you choose to add the concept to other plugins.

          Mark Waite added a comment - - edited So if you've considered exposing the repository name but have discarded it, then the bitbucket plugin will contributes to the environment variables with repository name (repo_slug in atlassian terms). If you've never considered the idea, maybe this is a good opportunity and I'll hold off on the task while I wait for the SCMHead method to be implemented. I've never considered the idea. I don't see enough benefit to adding more parsed segments of the repository URL, so I'm unlikely to add it to the git plugin or the git client plugin. No objection from me if you choose to add the concept to other plugins.

            nfalco Nikolas Falco
            chadiem Chadi El Masri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: