pipe: atlassian/jenkins-job-trigger:0.1.2
Asked by Shahar Senior:

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


Answers:
author: lissyaka
body: [@Shahar Senior](/t5/user/viewprofilepage/user-id/4954409) 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.  

comments: author: Manish Pal
body: [@lissyaka](/t5/user/viewprofilepage/user-id/4871214)   

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.


author: lissyaka
body: I will check this


author: lissyaka
body: [@Manish Pal](/t5/user/viewprofilepage/user-id/4967353). This pipe checks if [file present in directory](https://bitbucket.org/atlassian/jenkins-job-trigger/src/bf64818faac38824f5dccae090142b18497aa3c9/pipe/pipe.py#lines-119).  

Also there is a [test that checks if build from file is working correctly.](https://bitbucket.org/atlassian/jenkins-job-trigger/src/bf64818faac38824f5dccae090142b18497aa3c9/test/test.py#lines-85)

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
```


author: Igor Stoyanov
body: [@Shahar Senior](/t5/user/viewprofilepage/user-id/4954409) [@Manish Pal](/t5/user/viewprofilepage/user-id/4967353) we released a new version of [jenkins-job-trigger:0.2.0](https://bitbucket.org/atlassian/jenkins-job-trigger/src/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.


author: Patrik S
body: Hello [@Shahar Senior](/t5/user/viewprofilepage/user-id/4954409) ,

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](/t5/user/viewprofilepage/user-id/4954409) .

Kind regards,

Patrik S


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

jenkins