1

I have a projects that uses a multibranch pipeline to fetch all branches of a git server and then builds it. I need to do some post build actions there, but for some reason there is not post action configuration available in the builds. Neither in the multibranch pipeline nor the fetched sub projects. But the post build configuration is available in normal Jenkins jobs.

So far the only way I know of is to adjust the Jenkinsfile. But it would be great to do some work in the Jenkins frontend instead. Edit: Another way I found is to create a Freestyle project that will be triggered when the target branch inside the multibranch project has been successfully build. The downside here is that the project has to be run a second time because I cannot access the jar files of the other branch.

Is there a way to add post build steps to such a job? If so, how?

1 Answers1

1

The main idea behind the Jenkinsfile is to have your "infrastructure as code". So going by this, your job configuration including the post-build steps, should be version controlled in SCM.

To add post build steps to a Multibranch Pipeline:

node {

    try {
        stage("Checkout") {
            // checkout scm
        }

        stage("Build & test") {
            // build & Unit test
        }
    } catch (e) {
        // fail the build if an exception is thrown
        currentBuild.result = "FAILED"
        throw e
    } finally {
        // Post build steps here
        /* Success or failure, always run post build steps */
        // send email
        // publish test results etc etc
    }
}

For most of the post-build steps you would want there are online examples of them on how to write in pipeline format. If you have any specific one please list it

bp2010
  • 2,342
  • 17
  • 34