Skip to content
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

Unify the Trigger build loop for GHA and non-GHA builds #92

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

yosifkit
Copy link
Member

@yosifkit yosifkit commented Nov 5, 2024

This is an attempt to unify the queue loop. I wanted to do it without the node allocation and curl (i.e., entirely in java/groovy), but the java URL class methods are disallowed in the sandbox (security concern of reading local files of the Jenkins node).

So, without installing the HTTP Request plugin, we can't post to a URL without curl (and thus a node allocation) and it is unfortunately mostly unmaintained: "This plugin is up for adoption! We are looking for new maintainers"

#91 will be rebased on this if/when this is merged.

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Just a few minor things -- shuffling things around a tiny bit but overall I like it 👀 👍 ❤️

propagate: false,
quietPeriod: 5, // seconds
)
// TODO do something useful with "res.result" (especially "res.result != 'SUCCESS'")
Copy link
Member

Choose a reason for hiding this comment

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

This is TODONE (we can just delete the line instead of moving it) 😅

Suggested change
// TODO do something useful with "res.result" (especially "res.result != 'SUCCESS'")

Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I deleted the wrong TODO comment. 🙈

Comment on lines 122 to 125
set -Eeuo pipefail

Copy link
Member

Choose a reason for hiding this comment

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

This defaults to "the system default shell with set -ex" when a shell isn't specified (and we're not using any Bashisms anymore like we were previously):

Suggested change
set -Eeuo pipefail
set -u +x

url: res.absoluteUrl,
endTime: (res.startTimeInMillis + res.duration) / 1000.0, // convert to seconds
]
error()
Copy link
Member

Choose a reason for hiding this comment

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

Since we got rid of the echo, we could stuff res.result in here (because otherwise it's an exception without a message, which is kind of silly but we don't really have any more information here than "the job failed" 😂)

Suggested change
error()
error(res.result)

@@ -70,6 +71,7 @@ node {
| index($arch)
)
)
| .payload = (gha_payload | @json)
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd rather call this gha_payload explicitly, and only generate/set/return it when it's actually necessary (which we can then use further down as the determiner so that this becomes the only block that knows/cares about BASHBREW_ARCH=gha):

Suggested change
| .payload = (gha_payload | @json)
| if env.BASHBREW_ARCH == "gha" then
.gha_payload = (gha_payload | @json)
else . end


for (buildObj in queue) {
def identifier = buildObj.source.arches[buildObj.build.arch].tags[0]
if (env.BASHBREW_ARCH == 'gha') {
Copy link
Member

Choose a reason for hiding this comment

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

As a more generic way to phrase this (so that BASHBREW_ARCH=gha is embedded only in the jq above):

Suggested change
if (env.BASHBREW_ARCH == 'gha') {
if (buildObj.build.arch != env.BASHBREW_ARCH) {

(essentially, if we don't already have an obvious single architecture that matches the one we're building, include the architecture in our "identifier" -- we could also add a | .identifier = ... to the jq above to move this up there too, but maybe that's a change too much for now 😄)


// "catchError" to set "stageResult" :(
catchError(message: 'Build of "' + identifier + '" failed', buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
if (env.BASHBREW_ARCH == 'gha') {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (env.BASHBREW_ARCH == 'gha') {
if (buildObj.gha_payload) {

withEnv([
'json=' + json,
'payload=' + buildObj.payload
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'payload=' + buildObj.payload
'payload=' + buildObj.gha_payload,

withEnv([
'json=' + json,
'payload=' + buildObj.gha_payload
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'payload=' + buildObj.gha_payload
'payload=' + buildObj.gha_payload,

🙈

propagate: false,
quietPeriod: 5, // seconds
)
// TODO do something useful with "res.result" (especially "res.result != 'SUCCESS'")
Copy link
Member

Choose a reason for hiding this comment

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

👀

@yosifkit yosifkit merged commit 4b78106 into docker-library:main Nov 7, 2024
1 check passed
@yosifkit yosifkit deleted the combine-loop branch November 7, 2024 20:37
@tianon tianon mentioned this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants