Share variables across deploy scripts


#1

Hi,

Is it possible to share a variable (environment) or so across deploy steps?

e.g.

      - deploy:
          name: Build and push Docker image
          command: |
            # ... generate version
            VERSION="1.0.0"
      - deploy:
          name: Deploy to swarm
          command: |
            echo $VERSION

Or perhaps a suggestion on how best to do?

Thanks


#2

Dumping env into file and then sourcing it in another step might do the trick. Might not be safe with parallelism

  - deploy:
      name: Build and push Docker image
      command: |
        # ... generate version
        echo "export VERSION=$VERSION" >> env_file
        echo "export SOMETHING_ELSE=value" >> env_file
  - deploy:
      name: Deploy to swarm
      command: |
        source env_file
        echo $VERSION

#3

Might be a good solution for what I have, since I’m doing it in deploy so parallel shouldn’t affect I suppose.

Will give it a shot, thanks again


#4

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.