I have a two branches with Yocto meta data that build slightly different images (one of these images have more packages installed that helps developing code). Every branch has pipeline script.
Currently, both branches build the image in the same build directory. I want each branch to have its own build directory with its metadata, such as sstate-cache... How to achieve this?
trigger:
- development-image
variables:
IMAGE_NAME: texas-image
IMAGE_FILE: texas-image.rootfs.wic.xz
META_LAYERS: yocto-meta-layers
YOCTO_RELEASE: kirkstone
YOCTO_SOURCES: yocto-linux
YOCTO_BUILD_DIR: build
FIT_IMAGE_DIR: tools/tftp_u-boot
FIT_IMAGE_NAME: puma
BOOT_OVER_ETH: boot-over-eth
IMAGE_FILE_BOOT_OVER_ETH: texas-image.rootfs.cpio.gz
IMAGE_DEVICE_TREE_EVM_BOARD: k3-am642-evm.dtb
IMAGE_DEVICE_TREE_SK_BOARD: k3-am642-sk.dtb
BOOTLOADER_IMAGE_BOOT_OVER_ETH: u-boot.img
TIBOOT3_BINARY_BOOT_OVER_ETH: tiboot3.bin
TISPL_BINARY_BOOT_OVER_ETH: tispl.bin
KERNEL_IMAGE_BOOT_OVER_ETH: Image
pool:
#vmImage: ubuntu-latest
name: Etteplan
stages:
- stage: SetupYoctoEnv
jobs:
- job: DownloadResources
displayName: 'Downloading resources and dependencies'
#workspace:
#clean: $(IMAGE_DIR)
steps:
- bash: |
echo $(Build.ArtifactStagingDirectory)
echo $(Build.SourcesDirectory)
echo $(Build.BinariesDirectory)
echo $(Common.TestResultsDirectory)
- checkout: self # self represents the repo where the initial Pipelines YAML file was found clean: true
clean: false
path: $(YOCTO_SOURCES)
#- task: DeleteFiles@1
# displayName: "Removing tmp directory"
# inputs:
# SourceFolder: $(YOCTO_BUILD_DIR)/tmp
# Contents: '*'
# RemoveSourceFolder: true
- bash: |
echo Creating directory structure
ls -l
mkdir -p ${META_LAYERS}
mkdir -p ${BOOT_OVER_ETH}
- bash: |
echo Fetching Yocto meta layers
pwd
if [[ ! -d poky ]]; then git clone -b ${YOCTO_RELEASE} git://git.yoctoproject.org/poky.git; fi
if [[ ! -d meta-openembedded ]]; then git clone -b ${YOCTO_RELEASE} git://git.openembedded.org/meta-openembedded; fi
if [[ ! -d meta-ti ]]; then git clone -b ${YOCTO_RELEASE} git://git.yoctoproject.org/meta-ti; fi
if [[ ! -d meta-arm ]]; then git clone -b ${YOCTO_RELEASE} https://git.yoctoproject.org/meta-arm/; fi
workingDirectory: $(META_LAYERS)
- job: PrepareEnv
displayName: 'Preparing Environment'
dependsOn: 'DownloadResources'
steps:
- checkout: none
clean: false
path: $(YOCTO_SOURCES)
- bash: |
echo Initializing Yocto build environment
source ${META_LAYERS}/poky/oe-init-build-env
echo "Adding layers to bblayers.conf"
pwd
if ! grep -q meta-oe conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-openembedded/meta-oe; fi
if ! grep -q meta-python conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-openembedded/meta-python; fi
if ! grep -q meta-networking conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-openembedded/meta-networking; fi
if ! grep -q meta-arm-toolchain conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-arm/meta-arm-toolchain; fi
if ! grep -q meta-arm conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-arm/meta-arm; fi
if ! grep -q meta-ti-bsp conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-ti/meta-ti-bsp; fi
if ! grep -q meta-ti-extras conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/meta-ti/meta-ti-extras; fi
if ! grep -q meta-rt conf/bblayers.conf; then bitbake-layers add-layer ../${META_LAYERS}/../meta-rt; fi
- stage: BuildImage
dependsOn:
- SetupYoctoEnv
jobs:
- job: BuildImage
displayName: 'Building Yocto image'
timeoutInMinutes: 300
steps:
- checkout: none
clean: false
path: $(YOCTO_SOURCES)
- bash: |
source ${META_LAYERS}/poky/oe-init-build-env
bitbake ${IMAGE_NAME}
- job: BuildFitImage
displayName: 'Building Fit Image'
dependsOn: 'BuildImage'
steps:
- checkout: none
clean: false
path: $(YOCTO_SOURCES)
- bash: |
ln -s ../../$(YOCTO_BUILD_DIR)/tmp/deploy/images/am64xx-evm bin
ls -l bin
mkimage -f ${FIT_IMAGE_NAME}.its ${FIT_IMAGE_NAME}.itb
workingDirectory: $(FIT_IMAGE_DIR)
- stage: Publish
dependsOn:
- BuildImage
jobs:
- job: PublishImage
displayName: 'Publish Image'
steps:
- checkout: none
- task: CopyFiles@2
displayName: 'Collecting files boot over ethernet'
inputs:
sourceFolder: '$(YOCTO_BUILD_DIR)/tmp/deploy/images/am64xx-evm'
contents: |
$(IMAGE_FILE_BOOT_OVER_ETH)
$(IMAGE_DEVICE_TREE_EVM_BOARD)
$(IMAGE_DEVICE_TREE_SK_BOARD)
$(BOOTLOADER_IMAGE_BOOT_OVER_ETH)
$(TIBOOT3_BINARY_BOOT_OVER_ETH)
$(TIBOOT3_BINARY_BOOT_OVER_ETH)
$(TISPL_BINARY_BOOT_OVER_ETH)
$(KERNEL_IMAGE_BOOT_OVER_ETH)
overWrite: true
targetFolder: '$(BOOT_OVER_ETH)'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(BOOT_OVER_ETH)
archiveType: 'zip'
archiveFile: $(BOOT_OVER_ETH).zip
replaceExistingArchive: true
verbose: true
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(BOOT_OVER_ETH).zip
artifactType: 'pipeline'
artifactName: $(BOOT_OVER_ETH)
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(YOCTO_BUILD_DIR)/tmp/deploy/images/am64xx-evm/$(IMAGE_FILE)
artifactType: 'pipeline'
artifactName: $(IMAGE_NAME)
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(FIT_IMAGE_DIR)/$(FIT_IMAGE_NAME).itb
artifactType: 'pipeline'
artifactName: fit-image-$(FIT_IMAGE_NAME)
Thanks for help:)
CodePudding user response:
All builds will happen in the same build
folder, because you did not pass build name to source ${META_LAYERS}/poky/oe-init-build-env
in the BuildImage
job.
So, each time you run the pipeline, the oe-init-build-env
will source the same build.
You can create new variable to get the branch name automatically and then:
variables:
BRANCH_NAME: example
..
- job: BuildImage
displayName: 'Building Yocto image'
timeoutInMinutes: 300
steps:
- checkout: none
clean: false
path: $(YOCTO_SOURCES)
- bash: |
source ${META_LAYERS}/poky/oe-init-build-env -b $(BRANCH_NAME)
^
|
--------------------------------------------------------/