Bitbucket 管道如何合并两个变量以生成另一个变量以在其他地方使用
Bitbucket pipelines how to merge two variables to produce another variable to be used somewhere else
我正在尝试使用 bitbucket-pipelines.yml
来锻炼 Bitbucket 管道
image: microsoft/dotnet:sdk
pipelines:
branches:
master:
- step:
script:
- dotnet build $PROJECT_NAME
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- '[ ! -e "$BITBUCKET_CLONE_DIR/$EnvrBuild" ] && mkdir $BITBUCKET_CLONE_DIR/$EnvrBuild'
- dotnet publish $PROJECT_NAME --configuration Release
- cp -r $BITBUCKET_CLONE_DIR/$PROJECT_NAME/bin/Release/netcoreapp2.1/publish/** $BITBUCKET_CLONE_DIR/$EnvrBuild
artifacts:
- $EnvrBuild/**
我是 Bitbucket 管道的新手。当我对 $EnvrBuild 进行回显时,我得到了正确的结果,但是 $EnvrBuild 在后续步骤中没有任何内容并且它不会产生任何工件,但是如果我对值进行硬编码,它就会起作用。有没有办法做类似 $BITBUCKET_BUILD_NUMBER+"_"+$BITBUCKET_BRANCH 的事情? (我知道这是错误的,但你明白我想要实现的目标。提前谢谢你
变量扩展不允许指定工件,你必须提供一个静态值。但是,您可以隐式地使用通配符在构建目录下存储多个子目录。这是一个例子:
image: microsoft/dotnet:sdk
pipelines:
branches:
master:
- step:
script:
- dotnet build $PROJECT_NAME
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- '[ ! -e "$BITBUCKET_CLONE_DIR/$EnvrBuild" ] && mkdir $BITBUCKET_CLONE_DIR/$EnvrBuild'
- dotnet publish $PROJECT_NAME --configuration Release
- mkdir -p $BITBUCKET_CLONE_DIR/build_dir/$EnvrBuild
- cp -r $BITBUCKET_CLONE_DIR/$PROJECT_NAME/bin/Release/netcoreapp2.1/publish/** $BITBUCKET_CLONE_DIR/build_dir/$EnvrBuild
artifacts:
- build_dir/**
- step:
script:
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- ls build_dir/$EnvrBuild
我正在尝试使用 bitbucket-pipelines.yml
来锻炼 Bitbucket 管道 image: microsoft/dotnet:sdk
pipelines:
branches:
master:
- step:
script:
- dotnet build $PROJECT_NAME
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- '[ ! -e "$BITBUCKET_CLONE_DIR/$EnvrBuild" ] && mkdir $BITBUCKET_CLONE_DIR/$EnvrBuild'
- dotnet publish $PROJECT_NAME --configuration Release
- cp -r $BITBUCKET_CLONE_DIR/$PROJECT_NAME/bin/Release/netcoreapp2.1/publish/** $BITBUCKET_CLONE_DIR/$EnvrBuild
artifacts:
- $EnvrBuild/**
我是 Bitbucket 管道的新手。当我对 $EnvrBuild 进行回显时,我得到了正确的结果,但是 $EnvrBuild 在后续步骤中没有任何内容并且它不会产生任何工件,但是如果我对值进行硬编码,它就会起作用。有没有办法做类似 $BITBUCKET_BUILD_NUMBER+"_"+$BITBUCKET_BRANCH 的事情? (我知道这是错误的,但你明白我想要实现的目标。提前谢谢你
变量扩展不允许指定工件,你必须提供一个静态值。但是,您可以隐式地使用通配符在构建目录下存储多个子目录。这是一个例子:
image: microsoft/dotnet:sdk
pipelines:
branches:
master:
- step:
script:
- dotnet build $PROJECT_NAME
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- '[ ! -e "$BITBUCKET_CLONE_DIR/$EnvrBuild" ] && mkdir $BITBUCKET_CLONE_DIR/$EnvrBuild'
- dotnet publish $PROJECT_NAME --configuration Release
- mkdir -p $BITBUCKET_CLONE_DIR/build_dir/$EnvrBuild
- cp -r $BITBUCKET_CLONE_DIR/$PROJECT_NAME/bin/Release/netcoreapp2.1/publish/** $BITBUCKET_CLONE_DIR/build_dir/$EnvrBuild
artifacts:
- build_dir/**
- step:
script:
- export EnvrBuild=Production_$BITBUCKET_BUILD_NUMBER
- ls build_dir/$EnvrBuild