如何解决$ TERM未在CIrcleCI上的gradlew ./assembleRelease上设置? [英] How to resolve $TERM not set on gradlew ./assembleRelease on CIrcleCI?

查看:353
本文介绍了如何解决$ TERM未在CIrcleCI上的gradlew ./assembleRelease上设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在构建步骤中, ./gradlew assembleRelease 它表明ENV VAR没有设置:

 解压缩/ home / circleci / .gradle / wrapper / dists / gradle-2.14.1-all / 8bnwg5hd3w55iofp58khbp6yv / gradle-2.14.1-all.zip to /home/circleci/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv 
设置可执行权限:/home/circleci/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/bin/gradle

FAILURE:构建失败,出现异常。

*问题出在哪里:
无法打开stdout终端:$ TERM未设置

我根据这篇文章设置$ TERM变量是gradle调用之前的运行命令。但是,构建仍然无法找到这个变量。



问题:

你如何解决$ TERM未设置在gradlew上./assembleRelease在CIrcleCI上?



我根据这个SO帖子验证了我使用了正确的docker镜像:



https://stackoverflow.com/a/45744987/1829251



以下是 android CI作业的config.yml要点:



<$ p $
$ b $ docker:
- image:circleci / android:api-25-node8-alpha
步骤:
working_directory:〜/ repo / android $ b $ :
- 结帐:
路径:〜/ repo
- restore_cache:
key:jars - {{checksumbuild.gradle}} - {{checksumapp / build .gradle}}
- attach_workspace:
at:〜/ repo
- run:./gradlew androidDeperency
- run:export TERM = xterm
- run: sudo chmod + x ./gr adlew
- 运行:./gradlew assembleRelease
- save_cache:
路径:
- 〜/ .gradle
key:jars - {{checksumbuild.gradle }} - {{checksumapp / build.gradle}}
- store_test_results:
path:〜/ repo / android / reports

解决方案

免责声明:CircleCI中的开发者宣言

   - 运行:export TERM = xterm 

变量 $ TERM 仅适用于特定的shell。每个 run 步骤启动一个全新的shell。



运行 gradlew

   -  run:export TERM = xterm&& ./gradlew androidDeperency 

另一个是正确导出 $ TERM ,以便后面的所有步骤都可以看到变量。这可以这样做:

   -  run:echo'export TERM = xterm'>> $ BASH_ENV 

$ BASH_ENV 包含在每个CircleCI 步骤开始处获取的Bash文件。这是来自哪里: https://circleci.com/docs/2.0 / env-vars /#setting-path

I'm building a workflow on circleci 2.0 and so far jobs are running until it gets to android job.

At the build step ./gradlew assembleRelease it fails stating that an ENV VAR is not set:

Unzipping /home/circleci/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1-all.zip to /home/circleci/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
Set executable permissions for: /home/circleci/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/bin/gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not open terminal for stdout: $TERM not set

What I did try according to this post is setting the $TERM variable is a run command prior to the gradle invocation. But the build still fails looking for this variable.

Question:

How can you resolve $TERM not set on gradlew ./assembleRelease on CIrcleCI?

I did verify that I'm using the correct docker image according to this SO post:

https://stackoverflow.com/a/45744987/1829251

Here is the config.yml gist of the android CI Job:

 android:
    working_directory: ~/repo/android
    docker:
      - image: circleci/android:api-25-node8-alpha
    steps:
      - checkout:
          path: ~/repo
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - attach_workspace:
          at: ~/repo
      - run: ./gradlew androidDepedencies    
      - run: export TERM=xterm   
      - run: sudo chmod +x ./gradlew
      - run: ./gradlew assembleRelease
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - store_test_results:
path: ~/repo/android/reports

解决方案

disclaimer: Developer Evangelist at CircleCI

      - run: export TERM=xterm

That line sets the variable $TERM only for that specific shell. Each run step starts a brand new shell.

Your solution of running gradlew in the same step is one possible solution:

 - run: export TERM=xterm && ./gradlew androidDepedencies  

Another would be to properly export $TERM so that all subsequent steps can see the variable. This would be done like this:

      - run: echo 'export TERM=xterm' >> $BASH_ENV

$BASH_ENV contains the path to the Bash file that is sourced at the beginning of every CircleCI step. Here's where this came from: https://circleci.com/docs/2.0/env-vars/#setting-path

这篇关于如何解决$ TERM未在CIrcleCI上的gradlew ./assembleRelease上设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆