Get build number of spawned job?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Get build number of spawned job?

ZillaYT
If I spawn a job in jenkins, like this

Pipeline1:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline1

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #100

Now if I start another pipeline at the same time Pipeline1 is running

Pipeline2:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline2

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #101

In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding build numbers that they spawned for CommonPipeline? I'm asking because CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need to get the artifact for their corresponding spawned CommonPipeline job#. Is this possible?

Hope that makes sense.

Thanks,
Chris


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/86259fca-8622-49ac-a35d-334a3ded2bb4n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get build number of spawned job?

ZillaYT
IOW, both Pipeline1 and Pipeline2 jobs have this

String buildNum = <spawned job build number>
copyArtifacts projectName: 'Utilities/Playground/ECS-dependecy-checker',
              fingerprintArtifacts: true,
              filter: 'SomeFile.yml'
              selector: specific(buildNumber)

What do I put in the <spawned job build number> ?

thanks,
Chris
On Wednesday, September 16, 2020 at 4:37:48 PM UTC-4 [hidden email] wrote:
If I spawn a job in jenkins, like this

Pipeline1:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline1

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #100

Now if I start another pipeline at the same time Pipeline1 is running

Pipeline2:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline2

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #101

In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding build numbers that they spawned for CommonPipeline? I'm asking because CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need to get the artifact for their corresponding spawned CommonPipeline job#. Is this possible?

Hope that makes sense.

Thanks,
Chris


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/84ff3365-dc81-4cfe-bc78-53b220387e05n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get build number of spawned job?

ZillaYT
In reply to this post by ZillaYT
IOW, both Pipeline1 and Pipeline2 jobs have this

String buildNum = <spawned job build number>
copyArtifacts projectName: 'CommonPipeline',
              fingerprintArtifacts: true,
              filter: 'SomeFile.yml'
              selector: specific(buildNumber)

What do I put in the <spawned job build number> ?

thanks,
Chris
Reply all
Reply to author
Forward


On Wednesday, September 16, 2020 at 4:37:48 PM UTC-4 [hidden email] wrote:
If I spawn a job in jenkins, like this

Pipeline1:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline1

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #100

Now if I start another pipeline at the same time Pipeline1 is running

Pipeline2:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline2

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #101

In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding build numbers that they spawned for CommonPipeline? I'm asking because CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need to get the artifact for their corresponding spawned CommonPipeline job#. Is this possible?

Hope that makes sense.

Thanks,
Chris


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8b621d9c-10b0-4c67-b944-407ac742f827n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get build number of spawned job?

Gianluca
You can pass parameters to downstream jobs (Jenkins terminology for the jobs started via "build job") with the BUILD_ID of the upstream job (Jenkins terminology for the job that called "build job"):

build job: "CommonPipeline", wait: true, parameters: [ [name: UPSTREAM_ID, value: env.BUILD_ID], ... ]

Cheers,
Gianluca.

Il giorno mercoledì 16 settembre 2020 alle 21:47:26 UTC+1 [hidden email] ha scritto:
IOW, both Pipeline1 and Pipeline2 jobs have this

String buildNum = <spawned job build number>
copyArtifacts projectName: 'CommonPipeline',
              fingerprintArtifacts: true,
              filter: 'SomeFile.yml'
              selector: specific(buildNumber)

What do I put in the <spawned job build number> ?

thanks,
Chris
Reply all
Reply to author
Forward


On Wednesday, September 16, 2020 at 4:37:48 PM UTC-4 [hidden email] wrote:
If I spawn a job in jenkins, like this

Pipeline1:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline1

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #100

Now if I start another pipeline at the same time Pipeline1 is running

Pipeline2:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline2

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #101

In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding build numbers that they spawned for CommonPipeline? I'm asking because CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need to get the artifact for their corresponding spawned CommonPipeline job#. Is this possible?

Hope that makes sense.

Thanks,
Chris


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/18ffff89-f831-4446-8498-80c5034d0aa1n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get build number of spawned job?

ZillaYT
Thanks Gianluca, again.

However, I found out it's much easier. I do this for each Pipeline1 and Pipeline2

def commonJOb = build job: "CommonPipeline",
                      wait: true

copyArtifacts projectName: 'CommonPipeline',
              fingerprintArtifacts: true,
              filter: 'SomeFile.yml',
              selector: specific(commonJob.number.toString())


On Wednesday, September 16, 2020 at 4:54:30 PM UTC-4 Gianluca wrote:
You can pass parameters to downstream jobs (Jenkins terminology for the jobs started via "build job") with the BUILD_ID of the upstream job (Jenkins terminology for the job that called "build job"):

build job: "CommonPipeline", wait: true, parameters: [ [name: UPSTREAM_ID, value: env.BUILD_ID], ... ]

Cheers,
Gianluca.

Il giorno mercoledì 16 settembre 2020 alle 21:47:26 UTC+1 [hidden email] ha scritto:
IOW, both Pipeline1 and Pipeline2 jobs have this

String buildNum = <spawned job build number>
copyArtifacts projectName: 'CommonPipeline',
              fingerprintArtifacts: true,
              filter: 'SomeFile.yml'
              selector: specific(buildNumber)

What do I put in the <spawned job build number> ?

thanks,
Chris
Reply all
Reply to author
Forward


On Wednesday, September 16, 2020 at 4:37:48 PM UTC-4 [hidden email] wrote:
If I spawn a job in jenkins, like this

Pipeline1:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline1

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #100

Now if I start another pipeline at the same time Pipeline1 is running

Pipeline2:
build job: "CommonPipeline",
      wait: true

You see this in the Jenkins console for Pipeline2

Scheduling project: CommonPipeline
Starting building: Starting build CommonPipeline #101

In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding build numbers that they spawned for CommonPipeline? I'm asking because CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need to get the artifact for their corresponding spawned CommonPipeline job#. Is this possible?

Hope that makes sense.

Thanks,
Chris


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9b1a0d4c-ec38-44b4-b4e4-f302fcc9e7e3n%40googlegroups.com.