GitSCM is marked as Serializable but can't be serialized because of GitSCM.extensions

34 views
Skip to first unread message

Réda Housni Alaoui

unread,
Jul 16, 2023, 6:43:18 AM7/16/23
to Jenkins Developers
Hi everyone,

I'd like to understand how am I supposed to handle GitSCM in a StepExecution.


If I remove the transient modifier from the GitScm attribute, I will get java.io.NotSerializableException: hudson.util.DescribableList.

Is GitPushStep already doing that correctly? If yes, what are the consequences of this lack of serialization?

Mark Waite

unread,
Jul 18, 2023, 8:25:49 AM7/18/23
to Jenkins Developers
GitSCM is not serializable.  It is correct to not attempt to serialize it.  Can you explain why you believe that you need to serialize it? 

Réda Housni Alaoui

unread,
Jul 18, 2023, 10:02:43 AM7/18/23
to Jenkins Developers
Given GitScm exends GitSCMBackwardCompatibility and GitSCMBackwardCompatibility implements Serializable, I though it was expecting it to be serializable.

Jesse Glick

unread,
Jul 18, 2023, 10:03:37 AM7/18/23
to jenkin...@googlegroups.com
I guess the question is prompted by https://github.com/jenkinsci/git-push-plugin/blob/5c9525da6da7bed8fd70e8a45d62eafd1daad3f1/src/main/java/io/jenkins/plugins/git_push/GitPushStep.java#L109 which is odd because while `StepExecution` in general is `Serializable`, a `SynchronousNonBlockingStepExecution` does not need to be meaningfully serializable since it will just be aborted across a controller restart. In other words the `readObject` and `writeObject` methods are useless and could be deleted.

`GitPushStep` as a whole seems dubious anyway, since you can just write e.g.

withGit(…) {
  sh 'git push …'
}

(More realistically, the `git push` would be embedded in some larger script.)
Reply all
Reply to author
Forward
0 new messages