@@ -62,6 +62,14 @@ export interface GlobalOptions {
6262 * A global OOP-style GitLab CI configurator.
6363 */
6464export class Config {
65+ /**
66+ * Remove internal-only properties (like remote) from job/template definitions before output.
67+ */
68+ private static stripInternalProps < T extends object > ( obj : T ) : T {
69+ // Remove 'remote' property (internal use only)
70+ const { remote : _remote , ...rest } = obj as Record < string , unknown >
71+ return rest as T
72+ }
6573 // Internal state directly on the instance instead of nested plain object
6674 private stagesValue : string [ ] = [ ]
6775 private jobsValue : Record < string , JobDefinitionWithRemote > = { }
@@ -627,6 +635,15 @@ export class Config {
627635 public getPlainObject ( ) {
628636 // Create a deep copy to avoid mutating internal state
629637 // Merge templates and jobs (templates first, then jobs can override)
638+ // Prepare jobs/templates for output, removing internal-only props
639+ const jobsOut : Record < string , JobDefinition > = { }
640+ for ( const [ name , job ] of Object . entries ( this . templatesValue ) ) {
641+ jobsOut [ name ] = Config . stripInternalProps ( job )
642+ }
643+ for ( const [ name , job ] of Object . entries ( this . jobsValue ) ) {
644+ jobsOut [ name ] = Config . stripInternalProps ( job )
645+ }
646+
630647 const copy : GitLabCi = JSON . parse (
631648 JSON . stringify ( {
632649 stages : this . stagesValue . length ? [ ...this . stagesValue ] : undefined ,
@@ -640,7 +657,7 @@ export class Config {
640657 default : this . defaultValue ,
641658 variables : Object . keys ( this . variablesValue ) . length ? { ...this . variablesValue } : undefined ,
642659 include : this . includeValue . length ? [ ...this . includeValue ] : undefined ,
643- jobs : { ... this . templatesValue , ... this . jobsValue } ,
660+ jobs : jobsOut ,
644661 } ) ,
645662 ) as GitLabCi
646663
0 commit comments