-
Notifications
You must be signed in to change notification settings - Fork 831
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
Support seed job creation in Configuration as Code, updated #1173
Conversation
…-as-code managed jenkins master Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
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.
LGTM. Please remove any noise from the code as mentioned in my comments. Can we close #1142?
|
||
@Override | ||
public GeneratedItems[] check(CNode config, ConfigurationContext context) throws ConfiguratorException { | ||
// Any way to dry-run a job-dsl script ? |
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.
No, not yet.
import io.jenkins.plugins.casc.model.CNode; | ||
|
||
/** | ||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a> |
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.
Please remove all author tags.
@daspilker Done would be great to get this into job dsl 🤞 as demonstrated by Matrix auth plugin the configurators can co-exist as long as the |
We just merged jenkinsci/configuration-as-code-plugin#845 |
There's no incremental build here @Casz |
I know, will have to deploy a snapshot 😆 |
@Casz Can I release this change anytime or do you need to remove Job DSL from jcasc-support plugin first? |
you can release it anytime @daspilker 🙌 it was just if you wanted proof that it works since we have some integrations tests. The PR would be very similar to jenkinsci/configuration-as-code-plugin#845 |
@daspilker let me get the integration tests working... 😓 Seems we might have trouble |
@Casz I did a manual test. I never used CasC before, I wanted to see how it works. Quite nice actually 👍 . This Job DSL section does not appear in the reference. Is that expected? |
Oh I just forgot to deploy all the snapshots... I only deployed the plugin not core... |
That is expected, we could add some sort of support for exporting like storing the sources. Shouldn't be too difficult 😓 |
What do you mean by storing the sources? Must that be done on the CasC side? Will that be available soon? I would also be fine with adding a wiki page with some examples that we can point to. https://github.com/jenkinsci/job-dsl-plugin/tree/master/docs will be pushed to the wiki on every Job DSL release. So you could add a short page to this PR. Maybe you have some existing docs from the support plugin? |
Existing docs are here: Seems retrieving from a url or file is undocumented there, it only has inline |
The configurator just has to describe the sources so it can be exported. |
@timja, I can't for the life of me figure out how to access the ScriptSource instances and describe them. Unless you have some ideas let's skip the export. I'll add some docs |
🎉 |
The release yesterday broke all of our jobs that are using some custom code we wrote in a shared-pipeline-library. I can provide more details about the custom code if needed, but the error message from the jenkins master is here. Jobs were working up until jenkins master ran auto-updates and pulled this new version down (from 1.72 to 1.73). Please advise.
|
Not sure whether you're actually using JCasC or not. if you're using JCasC you should define your shared libraries inside JCasC. You seem to have left out the context of where this error message appeared @linux-samurai Do you have JCasC installed or not? |
@Casz I did not write our shared library code, and still getting up to speed on Groovy coding, so please bear with me. We are not using the 'configuration as code' plugin, but do a lot of the similar functionality within our shared library that the configuration as code plugin looks to be doing. An example of one of our Jenkinsfiles is as follows, which loads the shared library:
We then have an 'archetype.groovy' in our shared library that takes the input and pulls that declarative pipeline code and injects the 'config_select'. We have a lot of custom DSL methods we wrote that allow us to extend the declarative pipeline a lot, for example we have a 'define' custom method that will take just about any input (string, boolean, key/value pair, array, etc). So this release of job-dsl plugin, and from the error, this specific PR, broke every job we have where this job-dsl-plugin is installed and where we are using our custom DSL methods in our shared library. We have downgraded to 1.72 to get unblocked, but I would like to help flesh out what the root cause is (in our code and how should we improve it or improvements or plugin code improvements) and help improve the code in general, because I wouldn't want us to be locked at this version forever. If you could let me know if there is something specific I can look for in our shared library code I can circle back. here is another example of a custom method that was written by the original author, in case it helps:``` @NonCPS
|
@Casz Sorry, I want to explicitly answer your questions, in case they were not laid out fully in my response earlier.
(job code)
In the shared library, the gcloud.groovy file is a bit lengthy, but here is what we are importing. I'd need to review the code a bit more, and get approval to share it. Initial review doesn't have any glaring sensitivity concerns.
|
Sounds like an optional plugin dependency issue? |
Nah, sounds we have duplicate symbols: job-dsl-plugin/job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/casc/FromFileScriptSource.java Line 27 in ff202a7
|
This has been reported as JENKINS-57218. Shouldn't symbols have their descriptor type as namespace? Why would the Pipeline DSL pick the |
Would the easiest fix be to rename fromFileScriptSource symbol to be something like?:
or
|
or |
I agree @daspilker it is a problem in the pipeline. It has been reported several times that Symbol lacks more control. |
This has broke our builds also. It fails in startup but also on pipeline executions. |
It seems the fix was: #1175 and jenkinsci/structs-plugin#45 |
FYI jenkinsci/configuration-as-code-plugin#1394 which is released in v1.41 should fix any ordering to the root elements so the job dsl seed job should load last. |
It is using a released version and the changes that have happened to the configurator in the meantime.
SeedJob configurator now has access to JCasC secrets.