Как в jenkins запустить последний успешный build проекта?

Пользователь

от margaret , в категории: Другие , 2 года назад

Как в jenkins запустить последний успешный build проекта?

Facebook Vk Ok Twitter LinkedIn Telegram Whatsapp

2 ответа

Пользователь

от olen.shanahan , 2 года назад

@margaret 

Jenkins provides several ways to run the last successful build of a project. One way is to navigate to the project's main page and click on the "Build Now" button. In the "Build with Parameters" section, select the "Use last successful build" option and click on the "Build" button. This will trigger a new build, using the parameters from the last successful build.


Another way to run the last successful build is to use the Jenkins API. You can use a tool like cURL to make a REST API call to Jenkins, using the following syntax:

1
curl -X POST "JENKINS_URL/job/JOB_NAME/build?delay=0sec"


Replace JENKINS_URL with the URL of your Jenkins instance and JOB_NAME with the name of your project. This will trigger a new build, using the parameters from the last successful build.


Note that in order to use the Jenkins API, you may need to authenticate and have the appropriate permissions for your Jenkins instance.

Пользователь

от amber_moore , год назад

@margaret 

To run the last successful build of a specific project in Jenkins, you can use the Jenkins CLI (Command Line Interface). Here are the steps:

  1. Install the Jenkins CLI on your local machine. You can find the installation instructions in the Jenkins documentation.
  2. Open a terminal or command prompt and navigate to the directory where you installed the Jenkins CLI.
  3. Run the following command to get the information about the last successful build of the project: java -jar jenkins-cli.jar -s JENKINS_URL get-job JOB_NAME --tree builds[number,status] --username USERNAME --password PASSWORD Replace JENKINS_URL with the URL of your Jenkins instance, JOB_NAME with the name of the project, USERNAME with your Jenkins username, and PASSWORD with your Jenkins password or API token. This command will display the build number and status of the last successful build.
  4. Run the following command to trigger a new build using the last successful build parameters: java -jar jenkins-cli.jar -s JENKINS_URL build JOB_NAME --parameters LastSuccessfulBuildNumber=BUILD_NUMBER --username USERNAME --password PASSWORD Replace JENKINS_URL with the URL of your Jenkins instance, JOB_NAME with the name of the project, USERNAME with your Jenkins username, PASSWORD with your Jenkins password or API token, and BUILD_NUMBER with the build number obtained from step 3. This command will start a new build with the parameters from the last successful build.


Remember to replace the placeholders with the correct values specific to your Jenkins environment.