Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add git commit SHA to Docker images #1225

Merged
merged 1 commit into from
Oct 25, 2021

Conversation

shaneog
Copy link
Contributor

@shaneog shaneog commented Oct 23, 2021

Add the full git commit SHA to the generated Docker images using the
org.opencontainers.image.revision metadata label.

Fixes #865
Closes #892

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@shaneog shaneog requested review from olivergondza and a team as code owners October 23, 2021 22:53
@shaneog shaneog force-pushed the feature/add-commit-sha-docker-label branch 2 times, most recently from 9f34e9e to 7c7ca49 Compare October 24, 2021 15:46
@shaneog
Copy link
Contributor Author

shaneog commented Oct 24, 2021

@MarkEWaite Seems that tests are failing now due to a docker rate limit:

docker: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit.```

@shaneog shaneog force-pushed the feature/add-commit-sha-docker-label branch from 7c7ca49 to 2898530 Compare October 24, 2021 16:32
Copy link
Member

@olivergondza olivergondza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Please fix the indent.

@shaneog shaneog force-pushed the feature/add-commit-sha-docker-label branch from 2898530 to 2a7f5c2 Compare October 24, 2021 18:22
Add the full git commit SHA to the generated Docker images using the
`org.opencontainers.image.revision` metadata label.

Fixes jenkinsci#865
Closes jenkinsci#892
@shaneog shaneog force-pushed the feature/add-commit-sha-docker-label branch from 2a7f5c2 to e2d535e Compare October 24, 2021 19:49
@timja timja requested a review from MarkEWaite October 24, 2021 19:52
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm willing to approve, but I'm unclear why the COMMIT_SHA is included in the Makefile when the JENKINS_SHA is not. I think that may need review from @timja or @dduportal

@timja
Copy link
Member

timja commented Oct 24, 2021

The tests have a fixed Jenkins sha while the repo commit will change all the time.

@shaneog
Copy link
Contributor Author

shaneog commented Oct 24, 2021

@MarkEWaite JENKINS_SHA is defined with a default value that can be overridden which is based on an external repository. You can see the overrides defined in several Dockerfile files.

COMMIT_SHA is based on this repository and so a static default cannot (and should not) be defined, therefore we must dynamically define it somewhere. The Makefile is the proper place to define this since it is the basis of all (most?) build commands used.

Note that I redefine it in .ci/publish.sh since it's possible that this script is called manually (as per the HACKING.adoc file).

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, thanks for the tests too

@timja timja merged commit 2369b5f into jenkinsci:master Oct 25, 2021
@shaneog shaneog deleted the feature/add-commit-sha-docker-label branch October 25, 2021 16:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a packaging Git commitId/Tag reference to Docker images
4 participants