refactor: convert Jenkinsfile to declarative pipeline syntax #4784
Conversation
| @@ -17,7 +18,7 @@ properties([ | |||
| /** | |||
| * Main pipeline definition for building the engine. | |||
| * | |||
| * It uses the Scripted Pipeline Syntax. | |||
| * It uses the Declarative Pipeline Syntax. | |||
| * See https://www.jenkins.io/doc/book/pipeline/#declarative-versus-scripted-pipeline-syntax | |||
skaldarnar
Jun 22, 2021
Member
Since it uses declarative syntax now, I think we can now better link to https://www.jenkins.io/doc/book/pipeline/syntax/
Since it uses declarative syntax now, I think we can now better link to https://www.jenkins.io/doc/book/pipeline/syntax/
|
This is clearly working. It's running the pipeline, the steps are all labelled, it's recording the results, etc. but my head hurts because there were some things I assumed must be true about the Declarative Pipeline syntax, and this is refuting my assumptions. For instance, I assumed that the way for Jenkins to support a different syntax was for that I assumed that the trick of converting these pipelines would be those But you just left them in there as-is? And it doesn't complain about it at all? Sheesh. |
|
So does "declarative pipeline syntax" actually use a different syntax at all, or are declarative Jenkinsfiles still evaluated as groovy and those are just a different set of methods, methods that are designed as a builder instead of doing immediate execution? |
@keturn according to https://www.jenkins.io/doc/book/pipeline/#declarative-versus-scripted-pipeline-syntax they are rather similar in "many of the individual syntactical components", so I guess from the basic structure they look pretty similar. The key difference seems to be the |
|
I've tested to make sure that I haven't tested the Publish block (because PR branches don't get published), but I'm optimistic enough to go ahead and see how it works in practice. |
| engine/build/resources/main/org/terasology/engine/version/versionInfo.properties, | ||
| natives/**, | ||
| build-logic/src/**, | ||
| build-logic/*.kts |
keturn
Jun 24, 2021
Contributor
+1 for this long-comma-separated-string formatting change
+1 for this long-comma-separated-string formatting change
| post { | ||
| always { |
keturn
Jun 24, 2021
Contributor
yep, replacing try/finally with post/always
yep, replacing try/finally with post/always
| -PmavenUser=${artifactoryUser} | ||
| -PmavenPass=${artifactoryPass} | ||
| ''' |
keturn
Jun 24, 2021
Contributor
We will want to confirm that this doesn't leak the credentials into the easily-viewable logs, but I think this style of quote should be fine for that.
We will want to confirm that this doesn't leak the credentials into the easily-viewable logs, but I think this style of quote should be fine for that.
| script { | ||
| // Trigger the Omega dist job to repackage a game zip with modules |
keturn
Jun 24, 2021
Contributor
Was not this inside the specialBranch conditional before? I agree it should be!
I'm not sure if there's a disadvantage to using a script block like this. I'm okay with assuming it's fine until we learn otherwise.
Was not this inside the specialBranch conditional before? I agree it should be!
I'm not sure if there's a disadvantage to using a script block like this. I'm okay with assuming it's fine until we learn otherwise.
jdrueckert
Jun 24, 2021
Author
Member
The problem I faced here is that ther is this when clause to only run a stage if a specific condition is met, but from what I found this is only available for whole stages, not for individual steps.
The alternative would be to create four different stages, each with the matching when expression.
I figured that with the script block we avoid the duplication and additional stages shown in the ui (of which at max one will ever be executed in a pipeline run).
The problem I faced here is that ther is this when clause to only run a stage if a specific condition is met, but from what I found this is only available for whole stages, not for individual steps.
The alternative would be to create four different stages, each with the matching when expression.
I figured that with the script block we avoid the duplication and additional stages shown in the ui (of which at max one will ever be executed in a pipeline run).
jdrueckert
Jun 24, 2021
Author
Member
And no, this was outside of the specialBranch conditional also before. Directly after it, to be precise.
And no, this was outside of the specialBranch conditional also before. Directly after it, to be precise.
|
Suggestions for future improvements:
|
|
Let's see in the master build that's being triggered now, whether the publish stage behaves properly. |
No description provided.