-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quick: Update Makefile to support git branches #801
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions
- How can I test this awesome?
- Is it already used on a another repo successfully?
- If so, does it's Jenkins build have code I can copy that will output the tag instead of the commit hash?
My thoughts on № 1 (testing):
- I tag the latest commit of this branch.
- I run a Jenkins build using the tag.
- I check DockerHub for image.
- I test deploy some guinea pig CMS.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test success.
- Build.
- Deploy.
- Open.
- See
git describe
isv4.6.0-18-g783b7fbd
. - See
…/site.css
comment hasv4.6.0-18-g783b7fbd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rstijerina, I must wait until the end of the build (which can be long) before I see docker tag
output.1
How could I see that output sooner? So I could copy-paste to Core-Portal-Deployments during build.
+ echo "Building '`$(DOCKER_IMAGE_BRANCH)`'…"
docker build -t $(DOCKER_IMAGE) \
- docker build -t $(DOCKER_IMAGE) \
+ docker build -t $(DOCKER_IMAGE_BRANCH) \
Footnotes
-
docker tag taccwma/core-cms:783b7fb taccwma/core-cms:test-update-makefile-support-branch-tags
↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wesleyboar Good suggestion. We could add DOCKER_IMAGE_BRANCH=...
and echo "Building '$(DOCKER_IMAGE_BRANCH)'…"
to the Jenkins build as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno about putting same script snippet in Makefile and Jenkins. If after using this a while, I feel the urge, then I'll think on a shared code solution or give in to copy-paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the jenkins build console output, you can see what the tag is going to be at the very top (before STEP 1 begins) in these lines (copied from your build job above - https://jenkins01.tacc.utexas.edu/job/Core_CMS_Build/1375/console):
Previous HEAD position was cadaf60... chore: v4.7.2 (#800)
HEAD is now at 783b7fb... rearrange vars
then a few lines later:
docker build -t taccwma/core-cms:783b7fb \
--target production \
--build-arg PROJECT_NAME="" \
--build-arg BUILD_ID="v4.6.0-18-g783b7fb" \
--build-arg NEEDS_DEMO="true" \
-f ./Dockerfile .
which is the same things you will see in STEP 25:
Building "Core" styles:
Tagging CSS version as @tacc/core-cms v4.6.0-18-g783b7fb | MIT | github.com/TACC/Core-CMS
and reflects what you get at the end of the build pipe if it is successful:
Step 28/28 : COPY --from=node_build /code/ /code
---> 2bbb8033c87f
Successfully built 2bbb8033c87f
Successfully tagged taccwma/core-cms:783b7fb
Does that help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this doesn't include the special char replacement done by the DOCKER_IMAGE_BRANCH
var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this (in the beginning):
Fetching origin
+ git checkout test-update-makefile-support-branch-tags
Previous HEAD position was cadaf60... chore: v4.7.2 (#800)
HEAD is now at 783b7fb... rearrange vars
+ git describe --exact-match --tags HEAD
test-update-makefile-support-branch-tags
still matches this output (at the very end):
docker push taccwma/core-cms:test-update-makefile-support-branch-tags
The push refers to repository [docker.io/taccwma/core-cms]
...
test-update-makefile-support-branch-tags: digest: sha256:6f28e24b0d468bd71a8d5fb4da2beb0bdc19e0620c1c07992c8b8a91ed4ca52c size: 3691
+ '[' test-update-makefile-support-branch-tags == main ']'
Is that because Wes names things well and therefore there was no real conversion of special characters from the value in the .env
file (CMS_TAG=test-update-makefile-support-branch-tags # v4.8.0 candidate
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if the branch was test/update-makefile-support-branch-tags
, that would not match with it being converted to test-update-makefile-support-branch-tags
by the DOCKER_IMAGE_BRANCH
var
Is that because Wes names things well and therefore there was no real conversion of special characters from the value
yeah, exactly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taoteg was right to look at other lines. What I want (most of the time) is available reliably enough via:
+ git describe --exact-match --tags HEAD
v4.8.0
Not a branch name, but it matches when I build via tag.
When I next need to build by branch, I [may return to] this.
Overview
This PR adds a new variable to the
Makefile
context:DOCKER_IMAGE_BRANCH
This variable will correspond to the git tag for the commit if it exists, else the branch name for the commit, with special characters replaced with
-
.