我正在尝试使用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的事情? (我知道这是错误的,但是您了解我要实现的目标。在此先谢谢您
答案 0 :(得分:1)
不允许使用可变扩展指定工件,必须提供静态值。但是,您可以隐式使用通配符将多个子目录存储在构建目录下。这是一个示例:
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