Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

pipe: atlassian/jenkins-job-trigger:0.1.2

Shahar Senior
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 1, 2022

When Trigger job with parameters 

JENKINS_URL: $JENKINS_URL
JENKINS_USER: $JENKINS_USER
JENKINS_TOKEN: $JENKINS_TOKEN
JOB_NAME: 'myJob'
JOB_PARAMETERS: { 'Commit_Hash': '$BITBUCKET_COMMIT' }
WAIT: 'true'
DEBUG: 'true' # Optional

 The Pipe Failed with :

 

✖ Pipe has failed with error:
HTTP ERROR 400 This page expects a form submission
You need to post /job/myJob/buildWithParameters instead of /job/myJob/build

3 answers

1 accepted

0 votes
Answer accepted
lissyaka June 3, 2022

@Shahar Senior  hi. This is a bug in the pipe. We will investigate this issue and update the pipe.

But there is a hidden feature you can use instead:

JENKINS_URL: $JENKINS_URL
JENKINS_USER: $JENKINS_USER
JENKINS_TOKEN: $JENKINS_TOKEN
JOB_NAME: 'myJob'
BUILD_FROM_FILE: 'path to the file with parameters'
WAIT: 'true'
DEBUG: 'true' # Optional

 where you can paste all your job parameters.

Cheers.

 

 

Manish Pal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2022

@lissyaka 

I created a file build.json with params in the root dir of the repository.
I am trying to set BUILD_FROM_FILE parameter with $

BITBUCKET_CLONE_DIR/build.json 

It says Jenkins jobfile doesnt exist on running the pipeline. 

Have tried with just setting value as build.json as well. Same error.
lissyaka June 15, 2022

I will check this

lissyaka June 16, 2022

@Manish Pal. This pipe checks if file present in directory.

Also there is a test that checks if build from file is working correctly.

Please, ensure you have a file when you run the pipeline.
To do this you can:

step:
name: trigger
script:
- ls # check your file is presented
- pipe: atlassian/jenkins-job-trigger:0.1.2
variables:
JENKINS_URL: $JENKINS_URL
JENKINS_USER: $JENKINS_USER
JENKINS_TOKEN: $JENKINS_TOKEN
JOB_NAME: 'myJob'
BUILD_FROM_FILE: 'path to the file with parameters'
WAIT: 'true'
DEBUG: 'true' # Optional
0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2022

@Shahar Senior @Manish Pal  we released a new version of jenkins-job-trigger:0.2.0 where we fixed usage of BUILD_FROM_FILE and JOB_PARAMETERS.

script:
  - pipe: atlassian/jenkins-job-trigger:0.2.0
    variables:
      JENKINS_URL: 'http://my-jenkinsio-host/job'
      JENKINS_USER: $JENKINS_USER
      JENKINS_TOKEN: $JENKINS_TOKEN
      JOB_NAME: 'staging-awesome-project-job'
      BUILD_FROM_FILE: 'path_to_file_from_repo/jenkins_file'
      JENKINS_FILE_PATH: 'path_to_file_on_jenkins_job_parameter/jenkins_file'
      WAIT: 'true'
      WAIT_MAX_TIME: 120

 

script:
  - pipe: atlassian/jenkins-job-trigger:0.2.0
    variables:
      JENKINS_URL: 'http://my-jenkinsio-host/job'
      JENKINS_USER: $JENKINS_USER
      JENKINS_TOKEN: $JENKINS_TOKEN
      JOB_NAME: 'staging-awesome-project-job'
      JOB_PARAMETERS: >
        {
           "test1": $TEST1,
           "test2": "test2"
        }
      WAIT: 'true'
      WAIT_MAX_TIME: 120

Please, provide us feedback if all works as expected.

Regards, Igor.

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 2, 2022

Hello @Shahar Senior ,

Welcome to Atlassian community!

From the error message you received it seems that when using parameters Jenkins expects you to call the /buildWithParameters endpoint, instead of /build

Could you please try updating your $JENKINS_URL to call the /buildWithParameters endpoint and check how it goes? 

Let me know in case you run into any issues or have any questions.

Thank you, @Shahar Senior .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events