我刚刚使用NativeScript + Angular开始一个新项目,并在Visual Studio Team Services中托管了代码。我是NativeScript的新手,但是我希望有一个Build Definition设置来为持续集成构建iOS和Android工件。
当我在本地构建时,我执行以下命令:tns build
但是我不清楚如何在团队服务构建定义中使用它。现在我的构建定义只包含
tns build
)它目前失败,因为它不知道tns
命令是什么,据我所知,我不能在代理上安装这些工具,因为它是托管实例。
欣赏任何想法或其他想法!
答案 0 :(得分:0)
这是答案,您需要设置全局目录并将其添加到路径。 随时删除调试注释。
echo 'This is the current path.'
echo $PWD
echo 'This is the global path.'
npm prefix -g
echo 'Setting the npm prefix path'
npm config set prefix "$PWD/NPM"
echo 'Setting path'
PATH=$PATH:"$PWD/NPM/bin"
npm install nativescript -g
echo "PATH: $PATH"
tns doctor
答案 1 :(得分:0)
我能够做到这一点。我在Azure Devops中完成了这个yaml管道。
- task: UseNode@1
displayName: "Use Node ${{ parameters.nodeVersion }}"
inputs:
version: XX.XX
- task: Npm@1
displayName: 'npm clean'
inputs:
command: custom
verbose: false
customCommand: 'run clean'
- task: Npm@1
displayName: 'npm install nativescript'
inputs:
command: custom
verbose: false
customCommand: 'install nativescript@6 -g'
- task: PythonScript@0
displayName: "Install python package six"
inputs:
scriptSource: 'inline'
script: |
import os
os.system("pip install six")
- task: InstallAppleProvisioningProfile@1
displayName: "Install an Apple provisioning profile"
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: ${{ parameters.iosProvisionProfile }}
- task: InstallAppleCertificate@2
displayName: "Install an Apple certificate"
inputs:
certSecureFile: 'devops-cn.p12'
certPwd: ${{ parameters.certificatePassword }}
keychain: 'temp'
signingIdentity: 'iPhone Distribution: Whatever Company'
- task: PythonScript@0
displayName: "Build"
env:
IOS_PROVISION_PROFILE_NAME: ${{ parameters.iosProvisionProfileName }}
IOS_IPA_FILE_NAME: ${{ parameters.iosIpaFileName }}
inputs:
scriptSource: 'inline'
script: |
import os, shutil
os.system("tns build ios --bundle --provision \"{}\" --for-device --release".format(os.environ.get('IOS_PROVISION_PROFILE_NAME')))
- task: UseNode@1
displayName: "Use Node XX.XX"
inputs:
version: XX.XX
- task: Npm@1
displayName: "npm install"
inputs:
command: 'custom'
customCommand: 'run clean'
- task: Npm@1
displayName: "npm install nativescript"
inputs:
command: 'custom'
customCommand: 'install nativescript@6 -g'
- task: PythonScript@0
displayName: "Build"
env:
AND_KEY_STORE_PASSWORD: ${{ parameters.androidKeyStorePassword }}
AND_KEY_STORE_ALIAS: ${{ parameters.androidKeyStoreAlias }}
AND_KEY_STORE_ALIAS_PASSWORD: ${{ parameters.androidKeyStoreAliasPassword }}
inputs:
scriptSource: 'inline'
script: |
import os
os.system("tns build android --bundle --release --key-store-path \"$(secureFile.secureFilePath)\" --key-store-password \"{}\" --key-store-alias \"{}\" --key-store-alias-password \"{}\"".format(os.environ.get('AND_KEY_STORE_PASSWORD'), os.environ.get('AND_KEY_STORE_ALIAS'), os.environ.get('AND_KEY_STORE_ALIAS_PASSWORD')))
答案 2 :(得分:-1)
您需要使用NPM任务添加安装NativeScript命令行界面,例如:
另一方面,您可以setup a private build agent,然后将其作为您的帐户运行(更改服务帐户)
注意:根据我的测试,它适用于Hosted Linux Preview代理;它会使托管代理(不支持的平台)抛出错误