2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

envmanでBitriseの環境変数を上書きしようとしたら罠にハマった

Posted at

やりたいこと

Bitriseの環境変数を上書きしたい!
リリースノートを道中で作って、GitHubとかAppCenterとかに使いまわしたくなってくる!

Bitriseではenvmanというのが使える!良さげ!
https://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/

使ってみた

envmanはこんな感じで環境変数を追加/更新ができる。

envman add --key MY_RELEASE_NOTE --value "This is the release note"

 
試しに適当な環境変数を作成し、Scriptを1つだけWorkflowに追加して試してみた。
スクリーンショット 2019-10-24 19.05.22.png

#!/usr/bin/env bash

envman add --key AGE --value '17'

echo "はっ、ナナは永遠の${AGE}歳なので! 誕生日でも歳は${AGE}歳です! ウサミン星のカレンダーです!"

 
認識が間違っていなければ、17歳として扱われるはずだ!
結果はどうかというと...

+------------------------------------------------------------------------------+

| (0) script@1.1.5                                                             |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.1.5                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2019-10-24T09:26:26Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
はっ、ナナは永遠の25歳なので! 誕生日でも歳は25歳です! ウサミン星のカレンダーです!
|                                                                              |
+---+---------------------------------------------------------------+----------+
| ✓ | script@1.1.5                                                  | 3.92 sec |
+---+---------------------------------------------------------------+----------+

そ、そんなバカな!17歳じゃないだと...?
これは何かの間違いだ!

公式ドキュメントを読むと、もしかして次のステップから有効なのか?そうに違いない!

You can expose env vars from one Step and make it available for every other Step performed after the Step during the build. You can use envman to manage env vars.

ということでScriptをもう1つ追加して、次のステップで出力してみると...

+------------------------------------------------------------------------------+

| (0) script@1.1.5                                                             |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.1.5                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2019-10-24T09:26:26Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
|                                                                              |
+---+---------------------------------------------------------------+----------+
| ✓ | script@1.1.5                                                  | 3.92 sec |
+---+---------------------------------------------------------------+----------+
                                          ▼
+------------------------------------------------------------------------------+

| (1) script@1.1.5                                                             |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.1.5                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2019-10-24T09:26:29Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
はっ、ナナは永遠の17歳なので! 誕生日でも歳は17歳です! ウサミン星のカレンダーです!|                                                                              |
+---+---------------------------------------------------------------+----------+
| ✓ | script@1.1.5                                                  | 2.48 sec |
+---+---------------------------------------------------------------+----------+

正確な年齢で扱われたぞ!!
アベナナは17歳!間違いないね!

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?