如何使用Visual studio online/Azure开发人员操作工具为nativescript设置CI/CD

如何使用Visual studio online/Azure开发人员操作工具为nativescript设置CI/CD,nativescript,nativescript-angular,Nativescript,Nativescript Angular,Im try so为Nativescript应用程序设置CI/CD管道,添加了用于安装节点和npm install的命令,但Nativescript具有所需的依赖项。我如何在不必创建安装和设置了nativescript及其所有依赖项的vm的情况下动态地在Azure开发人员操作系统上运行 因此,我使用了一个VM并在其上安装了nativescript,使用和代理连接到机器并构建解决方案,我使用jenkins也做了同样的事情,但jenkins在VM上运行,不,我想在azure dev ops上移动整个

Im try so为Nativescript应用程序设置CI/CD管道,添加了用于安装节点和npm install的命令,但Nativescript具有所需的依赖项。我如何在不必创建安装和设置了nativescript及其所有依赖项的vm的情况下动态地在Azure开发人员操作系统上运行

因此,我使用了一个VM并在其上安装了nativescript,使用和代理连接到机器并构建解决方案,我使用jenkins也做了同样的事情,但jenkins在VM上运行,不,我想在azure dev ops上移动整个管道


构建步骤中使用的命令:tns build android

如果您不想使用虚拟机,则每次为应用程序创建构建时,必须先安装nativescript所需的所有内容,然后再在其托管代理上构建它

有几件重要的事情需要注意。首先,您的存储库名称更改为“s”,这将与您的授权文件的命名相冲突。。。至少对我来说是这样。我用添加到存储库中的bash文件修复了这一问题,该文件更改了CODE\u SIGN\u authorities变量build.xcconfig中路径的名称。我在package.json文件中添加了一个npm run-authentice命令,以便在构建之前运行该命令。其次,您需要在Azure Devops项目的管道下的库部分中存储所有文件和安全密码。第三,使用经典编辑器是了解yaml的最佳朋友,因为大多数作业都有查看yaml的选项。您还可以使用经典编辑器作为YAML文件的替代

下面的YAML和bash文件展示了如何构建作为工件存储的ipa和apk文件的示例。然后,您可以使用它触发一个发布管道,将发布推送到play和app store

# YAML File
name: Release Build
trigger:
- release/* # will start build for pull request into release branch ie. realease/version_1_0_0, release/version_2_0_0

pool:
  vmImage: 'macOS-10.13'

variables:
  scheme: 's'   # default name/scheme created on this machine for ipa
  sdk: 'iphoneos'
  configuration: 'Release'


steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.14'
  displayName: 'Install Node.js'

# Download Secure File for Android
# Note: if multiple secure files are downloaded... variable name will change and break pipeline
- task: DownloadSecureFile@1
  displayName: 'download android keystore file'
  inputs:
    secureFile: myKeystore.keystore

#Install Apple Certificate(Distrobution)
- task: InstallAppleCertificate@2
  displayName: 'Install an Apple certificate Distribution (yourcertificate.p12)'
  inputs:
    certSecureFile: '00000000-0000-0000-0000-000000000000' # got id from viewing file in clasic editor for pipeline
    certPwd: '$(myCertificatePasswordP12)' # password stored in Library

# Install Apple Provisioning Profile(Distrobution)
- task: InstallAppleProvisioningProfile@1
  displayName: 'Apple Provisioning Profile(myProvisioningProfile.mobileprovision)'
  inputs:
    provisioningProfileLocation: 'secureFiles' # Options: secureFiles, sourceRepository
    provProfileSecureFile: '00000000-0000-0000-0000-000000000000' # Required when provisioningProfileLocation == SecureFiles

# General Set Up
- script: |
    npm install -g nativescript@latest
    npm install
  displayName: 'Install native script and node Modules'

# variable explination
# $DOWNLOADSECUREFILE_SECUREFILEPATH is keystore file downloaded earlier
# $KEYSTORE_PASSWORD refers to the environment variable in this script which references library variable
# $(MyPlayStoreAlias) refers to library variable for your apps alias
# $BUILD_SOURCESDIRECTORY location where apk is built to

# Android
- script: |
    tns build android --env.production --release --key-store-path $DOWNLOADSECUREFILE_SECUREFILEPATH --key-store-password $KEYSTORE_PASSWORD --key-store-alias $(MyPlayStoreAlias) --key-store-alias-password $KEYSTORE_PASSWORD --bundle --copy-to $BUILD_SOURCESDIRECTORY   #creates apk
  displayName: 'Build Android Release apk'
  env:
    KEYSTORE_PASSWORD: $(MyPlayStoreKeystore)

# create apk artifact
- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.SourcesDirectory)/app-release.apk' 
    artifactName: 'apkDrop'
  displayName: 'Publishing apkDrop artifact'

# have to use xcode 10.1 to meet min standards for uploading ipa... default version for this machine was lower than 10.1
#changing xcode version
- script: |
    xcodebuild -version
    /bin/bash -c "echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_10.1.app;sudo xcode-select --switch /Applications/Xcode_10.1.app/Contents/Developer"
    xcodebuild -version
  displayName: 'changing xcode to 10.1'

# Optional... was running into build issues with latest version
#downgrading cocoapods version
- script: |
    sudo gem uninstall cocoapods
    sudo gem install cocoapods -v 1.5.3
  displayName: 'Using cocoapods version 1.5.3'

#iOS
- script: |
    xcodebuild -version # makeing sure the correct xcode version is being used
    pip install --ignore-installed six  # fixes pip 6 error
    npm run entitle #custom bash script used to change entitlement file
    tns run ios --provision     #see what provisioning profile and certificate are installed... helpful for debugging
    tns build ios --env.production --release --bundle    #creates xcworkspace
  displayName: 'Build ios Release xcworkspace'

#build and sign ipa
- task: Xcode@5
  displayName: 'Xcode sign and build'
  inputs:
    sdk: '$(sdk)'   # custom var
    scheme: '$(scheme)' # must be provided if setting manual path to xcworkspace
    configuration: '$(configuration)'   # custom var
    xcodeVersion: 'specifyPath'
    xcodeDeveloperDir: '/Applications/Xcode_10.1.app' #using xcode 10.1
    xcWorkspacePath: 'platforms/ios/s.xcworkspace'
    exportPath: '$(agent.buildDirectory)/output/$(sdk)/$(configuration)'    #location where ipa file will be stored
    packageApp: true    #create ipa
    signingOption: manual
    signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)' # distribution certificate
    provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)' # distribution profile

#creating ipa artifact
- task: PublishBuildArtifacts@1
  displayName: 'Publishing ipaDrop artifact'
  inputs:
    pathtoPublish: '$(agent.buildDirectory)/output/$(sdk)/$(configuration)/s.ipa'
    artifactName: 'ipaDrop'
Bash文件

#!/usr/bin/env bash
# filename: pipeline-entitlements.sh
echo "Editing build.xcconfig"
TARGET_KEY="CODE_SIGN_ENTITLEMENTS"
REPLACEMENT_VALUE="s\/Resources\/YOURENTITLEMENTFILENAME.entitlements"
CONFIG_FILE="./app/App_Resources/iOS/build.xcconfig"
echo "Editing $TARGET_KEY and replaceing value with $REPLACEMENT_VALUE"
sed -i.bak "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" $CONFIG_FILE
echo "Finished editing build.xcconfig"

我的问题是,如果你让azure在那里动态创建VM,那么sudo在管道上不起作用,因此无法安装某些组件,我希望整个构建管道都位于azure dev optsinteresting上。。。我在动态创建的虚拟机上使用sudo(如上面的YAML示例所示),没有遇到任何问题。。。它会给你任何错误吗?哪些组件不能安装?坐在azure开发运营商上,你的意思是不是不使用你的回购协议中的YAML文件,而是使用他们的经典编辑器,你可以通过azure开发运营商网站在线编辑,还是我偏离了你的意思?只是想更好地理解是什么阻碍了你。我目前使用的是构建管道的经典方法,而不是使用yaml。下面是一个错误示例。下面的nativescript链接显示了成功生成所需的组件。我在我的开发机器上安装了,并且相信构建虚拟机上不存在。验证您的环境是否根据中描述的系统要求进行了配置。2019-04-25T09:06:15.9570473Z###[错误]Bash退出,代码为“127”。2019-04-25T09:06:15.9582276Z##[部分]完成:构建用于linux的调试APKSo。不确定这是有意还是无意,但为了构建iOS应用程序,您需要运行macOS虚拟机,这就是我的示例所使用的。如果你只构建安卓系统,你可以使用linux虚拟机,但我从来没有像我想为iOS和安卓系统构建的那样尝试过。如果你尝试切换到macOs,我打赌你会有更好的运气。这是mac上安装程序的链接。linux有什么特别的原因吗?我目前只为Android开发,这就是我使用linux的原因。