3

I'm having trouble with a Jenkins pipeline. The thing is, it seems one of the steps is running in parallel with another (not intentionally):

I have something like:

...
step("build"){
  bat [Visual Basic 6 compile command - vb6.exe file.vbp /outdir my/directory]
  if(fileExists("my/directory/output.dll"){
    println "SUCCESS"
  }else{
    error("error")
  }
  ...
}

Ok, the problem is: it checks if the files exist before it's written by the compile command... If I put a sleep 10 before the condition, it always runs OK (for now), but obviously, I don't want to have a sleep command in my pipeline.

I don't know if I can control better the order os execution or if maybe the fault lies in the vb6.exe that creates a thread to write the output and then the main thread returns success before the output being written... does this make sense? Does anyone know how may I solve this problem?

nyi
  • 3,123
  • 4
  • 22
  • 45
  • I don't know VB6, but the compiler could be doing that? One option is to use the [`waitUntil`](https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-waituntil-code-wait-for-condition) step so it is a little less time reliant - `waitUntil { fileExists("my/directory/output.dll") }` – mkobit May 02 '18 at 19:47
  • Sometimes we have issues with the Windows file caching. But probably as suggested the waitUntil step may help in that case as well. – Joerg S May 03 '18 at 04:23
  • @mkobit first of all, thank you for your answer! Yes, that could work, but the would be a problem in the case that the compilation failed. If it happened, the .dll would not be created and it would never leave the `waitUntil{...}` loop. VB6.exe does not return an error code (only the log file can tell me if there was an error during build), so I couldn't do something like `if(!error) waitUntil{...}` . And also, I don't know why but it's not generating the log file (yes, even adding the `/out log/dir/` to the command). – Guilherme Ferreira May 03 '18 at 12:08

1 Answers1

2

My solution is to make the VB6 compilation step blocking.

This is what I run when working locally on my machine:

cmd /c VB6.exe /make someproject.vbp

And it is also the approach used by the Jenkins Visual Basic 6 plugin (I am the author). See this.

froque
  • 442
  • 2
  • 13