-
Couldn't load subscription status.
- Fork 469
fix(jenkins): Correct scaffolder action descriptions and parameter handling #5849
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@backstage-community/plugin-scaffolder-backend-module-jenkins': major | ||
| --- | ||
|
|
||
| fix(jenkins): Correct buildJob parameter passing & enableJob description |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright 2024 The Backstage Authors | ||
| * Copyright 2025 The Backstage Authors | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't update these dates, the idea is they reflect when this code was added. 👍 |
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -13,8 +13,10 @@ | |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; | ||
| import Jenkins from 'jenkins'; | ||
| // Assuming 'z' for zod comes implicitly from createTemplateAction context | ||
|
|
||
| /** | ||
| * | ||
|
|
@@ -26,17 +28,30 @@ import Jenkins from 'jenkins'; | |
| export function buildJob(jenkins: Jenkins) { | ||
| return createTemplateAction({ | ||
| id: 'jenkins:job:build', | ||
| description: 'Run an existing job jenkins given a name', | ||
| description: | ||
| 'Run an existing Jenkins job given its name, optionally with parameters.', | ||
| schema: { | ||
| input: { | ||
| jobName: z => z.string({ description: 'Name of jenkins item' }), | ||
| jobParameters: z => z.record(z.any()).optional(), | ||
| jobName: z => | ||
| z.string({ description: 'Name of the Jenkins job to run' }), | ||
| jobParameters: z => | ||
| z | ||
| .record(z.string(), z.any()) | ||
| .describe( | ||
| 'Optional parameters for the Jenkins job (key-value pairs)', | ||
| ) | ||
| .optional(), | ||
| }, | ||
| }, | ||
|
|
||
| async handler(ctx) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep existing whitespace and avoid making changes that aren't needed for the task at hand. 👍 |
||
| ctx.logger.info(`Starting jenkins job ${ctx.input.jobName}`); | ||
| ctx.logger.info(`Starting Jenkins job: ${ctx.input.jobName}`); | ||
|
|
||
| const options = ctx.input.jobParameters | ||
| ? { parameters: ctx.input.jobParameters } | ||
| : undefined; | ||
|
|
||
| await jenkins.job.build(ctx.input.jobName, ctx.input.jobParameters); | ||
| await jenkins.job.build(ctx.input.jobName, options); | ||
| ctx.logger.info('Job started successfully!'); | ||
| }, | ||
| }); | ||
|
|
||
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.
Why do we need
zodadded here?Uh oh!
There was an error while loading. Please reload this page.
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.
Ah, good point! Since the schema was already using that z => ... syntax (which comes from Zod), I added it as an explicit dependency just to be safe and maybe make things easier if the schema needs more complex stuff later. But definitely happy to remove it if you prefer