0
votes

How should pipeline/jenkinsfile syntax look to be triggered by parameterized trigger via curl for example?

I'm having the pipeline that starts with:

pipeline{  
    parameters {
        string(name: 'mycommitid', defaultValue: 'nocommit', description: 'my parameterized build')   
    }
    properties([
        parameters([
            string(defaultValue: 'nocommit', description: 'fas', name: 'mycommitid')
        ])
    ])
    node{...}
}

By setting this in the code my pipeline won't be triggered, only if I set it manually in build triggers section in jenkins. But the goal is to use it in the multibranch pipelines and jenkinsfiles.

The output I'm getting is (the hash here is some random number i typed as example):

git rev-parse 4364576456fgds467734ss344c^{commit} # timeout=10 
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

Finished: FAILURE 

And having the commit passed, how do you advise should I build only that single revision?

1

1 Answers

0
votes

When defining parameters in groovy pipeline script, you should define them before the groovy script, in the job configuration.

Once you created your parameters in the job configuration you can access them in the groovy, with the syntax ${env.PARAM}.