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

I would like to use runners to run the test cases on pullrequest.

Win Yourself January 26, 2022

I would like to use runners to run the test cases on pullrequest, earlier i was using  bitbuckets infrastructure to run the test cases whenever i do PR for the target branch.

 

The benifit for this approch was: A special pipeline that only runs on pull requests initiated from within your repository. It merges the destination branch into your working branch before it runs. Pull Request 

But  as my test cases are started increasing ,  and was getting Container "Build" failure even using 2x as size, so decided to use Runners feature to run my test cases on self hosted server.

 

My question is.
- Can I use Runners to execute test cases whenever PR is raised.

- How can i get the benifit of "It merges the destination branch into your working branch before it runs" 

Thanks

1 answer

1 accepted

1 vote
Answer accepted
Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 28, 2022

Hi @Win Yourself ,

Thank you for contacting Atlassian Community, I'm Norbert from Bitbucket Cloud Support Team, it's nice to meet with you! 

I'd like to inform you what you would like to achieve is possible, you can do it the following way:

pipelines: 
pull-requests:
'**': #this runs as default for any branch not elsewhere defined

- step:
runs-on:
- self.hosted
script:
  - 
  - 

Answering your other question "How can i get the benifit of "It merges the destination branch into your working branch before it runs"

I'd like to inform you that this is fully automatic, once the Pipelines is initiated from a PR, it gets merged automatically.

Please let me know if you have any further question? We're here to help.

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Win Yourself January 30, 2022

Actually I have started working on this litle experiment, really appreciate your response on my questions. 

 

The docker command which we get while setting up the runner, that does the real trick.

 

Once again thanks @Norbert C 

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 30, 2022

You're welcome @Win Yourself , I'm glad to hear I could help :) 

Win Yourself February 1, 2022

Hi @Norbert C ,

I was able to run the pipeline on my hosted machine, but following things I have noticed.

 

1. When the pipeline successfully get executed or when it gets failed. It removes the created container.

And because of this whatever resources I am downloading via script in pipeline, those are also getting removed

2. And when I run the same pipeline again, then whole process gets repeated, which leads to unnecessary time consumption.

 

Is there any way where we can persist downloaded data in a container, i don't want to download the data again and again. 

 

Thanks Man

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 1, 2022

Hi @Win Yourself 

I would like to inform you that actually this is working as expected.

Basically how Pipelines works is that when someone pushes a commit or creates a pull requests, Bitbucket Pipelines temporarily creates a container, where it's cloning the repository and runs the script from bitbucket-pipelines.yml file. When the build successfully executes or fails, the container is getting destroyed as there are no more things to do.

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Like # people like this
Pritesh Tamhankar February 2, 2022

Thanks for your response @Norbert C 

Got it, it's also mentioned in the official doc. Link

In this doc it's also mentioned that we can use the SCP / Rsync.

could you please tell me, how can i use this command in bitbucket-pipelines.yml file,

where i can download/access/copy the resource from other server to running container, so whatever scripts i am calling from bitbucket-pipelines.yml they can use these resources.

 

Thanks Man

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 7, 2022

Hi @Pritesh Tamhankar 

You're welcome.

What I would like to recommend you is:

* Setup the SSH-keys between your host and Pipelines by following the steps here: https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/

* Once you setup the SSH keys, you can copy the files from the host to the Pipelines build by doing this command:

rsync -e "ssh -o StrictHostKeyChecking=no" -a username@ip.of.the.host:/<path.in.the.host> <directory in the container build>

Please let me know how it goes, I'm here to help :)

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Like Win Yourself likes this
Win Yourself February 15, 2022

Hi @Norbert C ,

Apologies for the delay in the response.

I will work on this.

Thanks again.

Win Yourself February 16, 2022

Hi  @Norbert C 

i have followed the documentation to setup ssh keys.

However i think i have missed something not able to figure out, what it is

currently i am getting connection refused error.
e1.PNG

what i have done.. to test this.

- created new repo

- generated ssh keys

- updated the know host

- added the public key in authorized_keys (remote server)

-add on to this, also added the remote server ssh key to bitbucket acc ---> personal settings --> ssh key section.

- and yes my bitbucket pipeline.yml looks simple, through command arg i am trying to execute bash script available on remote server.e2.PNG

could you share your thoughts on this.

 

Thanks Man

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2022

Hi @Win Yourself 

It seems that Pipelines is not capable to connect to your remote server.

Can you whitelist all the Bitbucket related IPs on your firewall and let us know if that fixes the issue? What are the IP addresses to configure a corporate firewall?

Please let me know.

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Like Win Yourself likes this
Win Yourself March 3, 2022

@Norbert CThanks for the response.

This step makes sense.

All good, thanks again.

Regards

Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2022

You're welcome @Win Yourself  I'm glad to hear I was able to assist you.

Have a great weekend ahead!

Best Regards,
Norbert
Atlassian Bitbucket Cloud Support

Like Win Yourself likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events