jenkins-infra / helpdesk

Open your Infrastructure related issues here for the Jenkins project
https://github.com/jenkins-infra/helpdesk/issues/new/choose
16 stars 10 forks source link

[INFRA-2530] Update jenkinsciinfra/plugin-site-api tag to use github release #2125

Closed jenkins-infra-bot closed 2 years ago

jenkins-infra-bot commented 4 years ago

It would be nice to use Github release as Docker image tag.

This implies changing this Jenkinsfile.

 

Once done we'll be able to automatically deploy new versions as defined by this

 


Originally reported by olblak, imported from: Update jenkinsciinfra/plugin-site-api tag to use github release
  • assignee: aneveux
  • status: Closed
  • priority: Trivial
  • resolution: Fixed
  • resolved: 2021-11-03T10:09:22+01:00
  • imported: 2022/01/10
jenkins-infra-bot commented 4 years ago

olblak:

It would be awesome to have similar tag for plugin-site

jenkins-infra-bot commented 4 years ago

raji_vaidy:

Hi, Can I work on this issue? This is my first issue here. I'm sure I'll be able to crack it with a little guidance.

jenkins-infra-bot commented 4 years ago

halkeye:

Your welcome to take it, I don't have any jenkins-infra specific examples

 

As for plugin-site, since the deploy isn't dockered, it doesn't need to be done.

jenkins-infra-bot commented 4 years ago

olblak:

Hi Rajalakshmi V greetings, you have to update a Jenkinsfile in order to use github release version instead of git commit as describe here, then you open a pull request and if it's merged then the next docker image will use github release version. you can use the git tag for this as it's the same

As far as I know we don't have example

jenkins-infra-bot commented 4 years ago

halkeye:

My own shared library might be a good reference - https://github.com/halkeye/jenkins-shared-library/blob/master/vars/buildDockerfile.groovy#L39-L53

jenkins-infra-bot commented 4 years ago

raji_vaidy:

Olivier Vernin, The Jenkins file mentioned in the ticket description is of the plugin-site. But in the previous comments, Gavin Mogan mentioned that changes to the plugin-site is not necessary.

The changes have to be made in this file itself, right? 

jenkins-infra-bot commented 4 years ago

halkeye:

https://github.com/jenkins-infra/plugin-site-api/blob/e03bcc67bcd2ea0a5068ae0cb66b4739ed38f3e3/Jenkinsfile#L73 is absolutely plugin-site-api

jenkins-infra-bot commented 4 years ago

raji_vaidy:

Hi Gavin Mogan

Thanks for the response. 

These are the things I need to do from what I understood:

  1. Instead of shortCommit have a different variable e.g latestRelase
  2. Instead of "rev-parse HEAD", I need to get the latest release tag and put it in the 'latestRelease' variable.
  3. Use this new variable in place of 'shortCommit'

Please correct if there's a miunderstanding.

Thanks

jenkins-infra-bot commented 4 years ago

halkeye:

more or less. 2 is where the meat of the work is.

`rev-parse HEAD` returns the current commit hash for like the current commit

https://stackoverflow.com/questions/3404936/show-which-git-tag-you-are-on has some ideas, specifically `git tag --points-at HEAD` looks like a good idea, which returns the tag name for the current version.

I don't know if olivier was thinking of removing the per commit docker images or not, but I'd check to see if the current commit is tagged, and docker tag $imageName:$tagName, then docker push $imageName:$tagName

jenkins-infra-bot commented 4 years ago

raji_vaidy:

Gavin Mogan, tried the commands out in my local.

`git tag --points-at HEAD` returns a blank if the current commit is untagged.

However, `git describe --tags --abbrev=0` always returns the recent tag.

[This|https://pasteboard.co/J42KIbX.png] is an image of my trial.

In my opinion, we can go with the latter. Please comment on the same.

jenkins-infra-bot commented 4 years ago

halkeye:

The goal is to push docker images that relate to a released tag.

 

If you use an older tag, then the docker image won't be on the right commit.

 

Tags are a point in time

 

If there's no tag on this commit, then don't push a docker image for a tag

 

jenkins-infra-bot commented 4 years ago

raji_vaidy:

Okay. 

So if there exists a tag for the current commit use that else use the commit id directly, am I right?

  1. So we run this command `git tag --points-at HEAD` first.
  2. If it returns a value, well and good.
  3. If it returns blank, we go with `git rev-parse HEAD` and proceed as usual.
jenkins-infra-bot commented 4 years ago

halkeye:

Sounds good to me.

jenkins-infra-bot commented 2 years ago

JIRAUSER134212:

Hi there!

Since the issue was not updated in more than a year, I gave it a try during this year's Hacktoberfest.

Here's a PR with my humble attempt to solve it: https://github.com/jenkins-infra/plugin-site-api/pull/108

Let me know if there's anything to do differently, I'm happy to learn more

Thanks a lot for your attention, and have a great day!

jenkins-infra-bot commented 2 years ago

dduportal:

Thanks for the PR Antoine Neveux