Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:19:11+00:00 2026-06-04T21:19:11+00:00

The following ‘Execute system Groovy script’ Build Task updates the build’s description to add

  • 0

The following ‘Execute system Groovy script’ Build Task updates the build’s description to add a button that will submit another Jenkins job which is parameterized:

import hudson.model.Cause
import hudson.model.Job
import jenkins.model.Jenkins

final JOB_NAME = 'my-job'

final jenkins = Jenkins.instance
final job = jenkins.getItemByFullName(JOB_NAME, Job.class)
final currentBuild = Thread.currentThread().executable
final buildNumber = currentBuild.getNumber()

job.builds
    .findAll { build -> build.number == buildNumber }
    .each { build ->
        build.setDescription("""
            <button
                type='button'
                onclick='javascript:
                    var another_job = function() {
                        parameters = {json: {parameter: [{name: "P4_CHANGELIST", value: "0"}]}};
                        new Ajax.Request("http://builds/job/another-job/build", {
                            method: "post",
                            parameters: Object.toJSON(parameters)
                        });
                    };
                    another_job()'>Continue</button>""")
    }

But upon clicking the Continue button, the request returns a 400 Bad Request. It looks like it’s because the build parameters aren’t being passed through correctly (if I remove the build parameters from another-job and don’t send through parameters, things work fine).

I’m not sure if the problem is due to bad quoting or the way I’m sending through the build parameters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:19:13+00:00Added an answer on June 4, 2026 at 9:19 pm

    You need to use JSON. See Submitting Jobs.

    The following worked for me:

    <button 
      type='button'
      onclick='javascript:
        var another_job = function() {
          new Ajax.Request("http://localhost:8081/job/JReport2/build", {
            method: "post",
            parameters: {json: Object.toJSON({parameter: [{name: "foo", value: "fobar"}]})}
        });
      };
      another_job()'>
      Start Job
    </button>
    

    What’s a bit strange that is works when the button that appears next to the build in the build list is pushed, but does not work with the button that appears on the build description itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a RegEx expression that will successfully parse the following
Following this JavaFX 2.0 tutorial I created a css file in eclipse that includes
Following is the stack trace. I read that the Broken Pipe is because of
Following String causes PatternSyntaxException : Pattern.compile(*\\.*); I want to create a pattern so that
Following the instructions at Add header (copyright) information to existing source files , I
Following the way Rob does it, I have the classes that are generated by
Following is a question that is posted on http://dev.eclipse.org in April 2003. The original
Following s my Code to display data to listview from database. But it will
Following is a code to display a button to the toolbar. UIButton myButton =
Following is the table and script of this table. DECLARE @temp TABLE (PPId INT,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.