Declarative script syntax: Archive from specific stage?

28 views
Skip to first unread message

David Aldrich

unread,
Jan 23, 2020, 11:12:34 AM1/23/20
to jenkins...@googlegroups.com

I have a question about declarative script syntax.

 

I have a multi-stage job, where each stage runs on a separate agent. Whether the job passes or fails, I want to archive some artefacts from the job, so I have to call archiveArtifacts from post::cleanup().

 

stages {

    stage(‘S1’) {

        agent { label “A” }

        steps {

        <snip>

    }

    stage(‘S2’) {

        agent { label “B” }

        steps {

        <snip>

    }

}

post {

    cleanup{ archiveArtifacts artifacts: '*.zip'}

}

 

My problem is that I want to archive the artifacts from a specific agent (i.e. a specific stage). How would I do that?

 

Best regards

David

vince bailey

unread,
Jan 23, 2020, 11:28:06 AM1/23/20
to 'Björn Pedersen' via Jenkins Users
--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAJK_iej6MzrtnHg-hf5p9SjsrHaNvJEDxkb3os6bdpTrRby4SQ%40mail.gmail.com.

David Aldrich

unread,
Jan 23, 2020, 11:35:13 AM1/23/20
to jenkins...@googlegroups.com

Thanks, but that doesn't address my situation where I have stages running on different agents and I want to archive results from a specific agent.

Liejun Tao

unread,
Jan 23, 2020, 12:41:16 PM1/23/20
to jenkins...@googlegroups.com
Did you try to write post after stage?

stages {

    stage(‘S1’) {

        agent { label “A” }

        steps {

        <snip>

    }

    post {

       xxx

    }

    stage(‘S2’) {

        agent { label “B” }

        steps {

        <snip>

    }

}

--
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 jenkinsci-use...@googlegroups.com.


--
Thanks,
Baibai

David Aldrich

unread,
Jan 23, 2020, 12:45:39 PM1/23/20
to jenkins...@googlegroups.com

> Did you try to write post after stage?

It seems that is not allowed:

WorkflowScript: 140: Expected a stage @ line 140, column 9.
           post{
           ^

Liejun Tao

unread,
Jan 23, 2020, 3:09:00 PM1/23/20
to jenkins...@googlegroups.com

--
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 jenkinsci-use...@googlegroups.com.


--
Thanks,
Baibai

David Aldrich

unread,
Jan 24, 2020, 3:48:12 AM1/24/20
to jenkins...@googlegroups.com

Thank you. That has fixed my problem.


David

Reply all
Reply to author
Forward
0 new messages