Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,334
Community Members
 
Community Events
175
Community Groups

pipe: atlassian/jenkins-job-trigger:0.1.2

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

@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.

 

 

@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.

I will check this

@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

@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 Jun 02, 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

Atlassian Community Events