bashjenkins-pipelinejenkins-groovy

bash block script step pipeline no executing on a pipeline1 called from other pipeline2


i have a pipeline1 that execute a bash script block success and run ok,BUT when i invoke this pipeline1 from pipeline2 the bash script block didn't executed.

Other sh individual line commands yes run ok and it showed output but into block script not be are executing

Any idea?

I am referencing to this:

pipeline1

  steps { 
        script{
          sh "echo Hello1 world"
          sh '''#!/bin/bash
          sh "echo Hello2 world"
          <commands>
          '''
        }
    }

pipeline2

steps { 
            build (job: '../../folfer1/pipeline1', parameters: [ 
            ... 
            ], wait: true) 
} 

Then, the output on pipeline2 showed

            echo 'Hello1 World'
            echo 'Hello2 World'

but not executing sh block bash and not showed any error, only showed Hello1 world

sh "echo Hello1 world"
sh '''#!/bin/bash
sh "echo Hello2 world"
<commands>
'''

reproduction

[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/folder1/pipeline1
[Pipeline] {
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Executing playbook playbook1)
[Pipeline] withEnv
[Pipeline] {
[Pipeline] script (hide)
[Pipeline] {
[Pipeline] echo
Hello1 world
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Resume:

if i invoke this pipeline1 from pipeline2 commands into block script not be are executing but, if I running pipeline1 alone the result and all executions are ok!)

Regards, Edu < allways learning


Solution

  • Ok, thanks to echo command I showed where pipeline reproduction is skipped execution code. Thanks @Iterokun