Matthieu Feron
Matthieu Feron

Reputation: 51

Looking for a jenkins pipeline build job syntax that really works

I'm trying to trigger a jenkins pipeline job from inside another jenkins pipeline job, with parameters.
I'm relatively newbie in java/groovy so I search the web for functional samples but all that I found are unusable for syntax or scripting reasons. Some of my tests below:

How to trigger another Jenkins pipeline that needs a $BRANCH variable?

node() {
    build job: 'INVENTORIES', propagate: true, wait: true
}
Failed: java.lang.NoSuchMethodError: No such DSL method 'build' found among steps [ansiblePlaybook

Jenkins pipeline for building other jobs

node() {
    stage('Desc1') {
        steps {
            dir('/var/lib/jenkins/workspace') {
                build job: 'INVENTORIES', propagate: true, wait: true
            }
        }
    }
}
Failed: java.lang.NoSuchMethodError: No such DSL method 'steps' found among steps [ansiblePlaybook,

node() {
    stages {
        stage ("build") {       //an arbitrary stage name
            steps {
                build 'INVENTORIES' //this is where we specify which job to invoke.
            }
        }
    }
}
Failed: java.lang.NoSuchMethodError: No such DSL method 'stages' found among steps [ansiblePlaybook,

I've tried plenty of samples (script block, step block, stage block...) but it never works, always throwing java exception like:

java.lang.ClassCastException: org.jenkinsci.plugins.workflow.steps.CoreStep.delegate expects interface jenkins.tasks.SimpleBuildStep but received class ...

Before I jump from a bridge, could anyone here helps me? Thanks in advance, I know swimming but it's a little cold

Upvotes: 0

Views: 3114

Answers (1)

Matthieu Feron
Matthieu Feron

Reputation: 51

[SOLVED] It were missing a Pipeline Plugin but the error messages wasn't clear enought and log content too poor to guess. Thanks to @zett42 to have pointed me on the good search way. Have a nice day.

Upvotes: 1

Related Questions