Is it possible to redirect a service name from localhost to http://service-name: port
image: python:3.8
pipelines:
default:
- parallel:
- step:
name: Test
services:
- redis-server
caches:
- pip
script:
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- pip install pytest
- cd files
- python3 -m pytest -v tests/test_app.py
definitions:
services:
redis-server:
image: redis:3.2
app.py
from distutils.log import debug
from itertools import count
from flask import Flask,render_template
from flask_redis import FlaskRedis
count = 0
app = Flask(__name__)
app.config['REDIS_URL'] = "redis://redis-server:6379/0"
#app.config['REDIS_DB'] = 0
redisclient = FlaskRedis(app)
@app.route("/")
def helloworld():
# exit(1) #1 means with error 0 is with error
global count
count = count +1
redisclient.set("value1",count)
return "HelloWorld: {0}".format(redisclient.get("value1").decode("utf-8"))
@app.route("/hello")
def hello():
return render_template("index.html", placeholder = "hello demo for Panos")
if __name__ == "__main__":
app.run(debug=True,host="0.0.0.0",port=5000)
app_test.py
import unittest
import app
def test_main():
assert "HelloWorld:" in app.helloworld()
how do i redirect from localhost to redis-server ?
Hi @nacbapat
Thank you for contacting Atlassian Community, I'm Norbert and I'm a Bitbucket Cloud Support Engineer, it's nice to meet with you! Welcome to the Atlassian Community!
Based on my observation, you would like to connect from your app to the redis service, which is running in Bitbucket Pipelines. As our documentation states, no port mapping or hostnames are required: https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.html
To connect, can I ask you to try to connect as:
"redis://localhost:6379/0"
Please let us know how it goes.
Best Regards,
Norbert
Atlassian Bitbucket Cloud Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.