How to start jenkins automatic work with variable parameters without using CLI

Scenario:

  • Jenkins runs on a server that I do not have access to. In this case, I cannot use the jenkins CLI.
  • I have access to jenkins web interface via url and I see progress in work and that’s it.
  • There is a build job configured for jenkins to work. It can be launched on demand using the web interface.

Demand:

Currently, I can specify the parameters that define this external event in the jenkins web interface and run the task. But this is a guide (I have to do this).

I want to complete the task above based on an external event in automatic mode, which means:

  • When an external event occurs, run the assembly that defines the parameters of this external event, wait for the assembly to complete, then if another event occurs, repeat.

Question:

Without using jenkins CLI, can I pass parameters defining an external event to jenkins url as POST url parameters?

Output:

This way, I can control the external event, and if that happens, send its parameters to jenkins url and run the build.

+4
source share
1 answer

You can start the job by sending a POST to the buildWithParameters . You can also just connect the query string and GET to this endpoint.

A few tips:

  • If your Jenkins instance is protected, you need to configure the build token.
  • If your Jenkins has CSRF protection, any POST must include valid crumb.

See: https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build and https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

+7
source

Source: https://habr.com/ru/post/1501751/


All Articles