Forums

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

what context or artifacts or variables are accessible during a pipeline deployment step?

bradrust October 15, 2020

I have been trying to setup a deployment step in my bitbucket-pipelines.yml but the documentation on what that step (in a typical or suggested workflow) is just not that clear.  All of the documentation has one-liners like "python deploy-to-prod.py".... ok,... what does that script *do* or *what* is that script acting on?

I see that you can set variables at the deployment level.  I am assuming people store credentials required to take action on your deployment (to push to a cloud resource).

What other variables does it have access to?... all of the variables that are used in other pipeline steps?

Does it have access to artifacts?

Could someone post a pseudo-code "deploy-to-prod.py" that might suggest a typical workflow of pushing the yielded build of a pipeline step to a production system.

 

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 21, 2020

Hi Brad,

A deployment step has access to artifacts defined in previous steps, repository variables, workspace variables, default variables as listed here: https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/, and variables defined for that specific deployment environment.

It doesn't have access to variables of other deployment environments. I am not sure what you are referring to with variables that are used in other pipeline steps? Do you mean variables that you defined in the script of previous steps?

I am not sure about the deploy-to-prod.py file as I've never used Python, but I believe that it would contain commands to push all or certain repo files or files you generated during the build to a remote server.

When you run a Pipelines build the repo is cloned in a Docker container, so repo files on that commit or files you create during the build can be deployed to a server.

There are different tools that can be used for deployment, you can check the following guide that has examples of deployments to different platforms, in case you use any of them:

In many of these use cases, deployment can be done with a pipe, so you may not need to have any additional commands. You can check e.g. the following deployment guide from the above page, you can use a certain pipe to deploy files to your server via SSH:

Other users may use e.g. git ftp for this purpose, in this case the deployment step would include git ftp commands.

I hope this helps, please feel free to let me know if you have any other questions.

Kind regards,
Theodora

bradrust October 21, 2020

Thanks for the reply.   I think maybe I was not thinking of the atomic content you describe here...  When you run a Pipelines build the repo is cloned in a Docker container, so repo files on that commit or files you create during the build can be deployed to a server.

I approached my deployment by using an artifact to store the docker image tag that should be deployed in the deployment step.   All of my projects build and push docker images so there really is no artifact.   I guess it's intuitive to others but an example of this would have helped me a lot.

Your answer is descriptive and helps.  In general, probably wasn't thinking of the step semantics with regard to the examples provided.

 

  - step:
script:
- docker login ....
- buildRelease.sh
-
 - # might be composed from facts known in this step only
- docker_tag=${BITBUCKET_BUILD_NUMBER}
-
- docker push ....
- echo export DOCKER_TAG=${docker_tag} > artifact-tag
artifacts:
- artifact-tag
- step:
deployment: test
script:
- source artifact-tag
- pipe: atlassian/google-gke-kubectl-run:1.3.0
variables:
# ... some reference to the DOCKER_TAG here

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events