hello,
as per suggestion here, i added the pipe.
Code:
steps:
- step: &Build
name: Build
services:
- docker
caches:
- docker
script:
- echo $BITBUCKET_USERNAME
- pipe: atlassian/bitbucket-clear-cache:3.1.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_USER_APP_TOKEN
- branch=$( echo "${BITBUCKET_BRANCH////_}" | tr '[:upper:]' '[:lower:]' )
- export IMAGE=$BITBUCKET_REPO_SLUG_$branch
- echo "export IMAGE=$IMAGE" > image.var
- export DOCKER_FILE="dockerfile"
- docker images
- docker builder build -t $IMAGE -f $DOCKER_FILE .
- docker images
artifacts:
- image.var
- step: &Deploy
name: Deploy Docker image
deployment: Test
services:
- docker
clone:
enabled: false
caches:
- docker
script:
- source image.var
- echo "Image - $IMAGE "
- docker images
- docker login -u $SERVICE_ACCOUNT -p $SERVICE_ACCOUNT_TOKEN
- docker push $IMAGE
on the first run, the "docker images" has no images, and after the "docker builder build" I do see :
docker images
+ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEfeature_smsms-44 latest bb3a0db7c4e6 About a minute ago 82.7MB
which is expected.
on the second run:
Build setup
...
Cache "docker": DownloadingCache "docker": Downloaded 71.4 MiB in 4 secondsCache "docker": ExtractingCache "docker": Extracted in 1 seconds
...pipe: atlassian/bitbucket-clear-cache:3.1.1+ docker container run \...
bitbucketpipelines/bitbucket-clear-cache:3.1.1INFO: Executing the pipe...✔ Retrieved 1 caches✔ Successfully cleared cache docker✔ Finished clearing cachesdocker images
...
+ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEfeature_smsms-44 latest bb3a0db7c4e6 About a minute ago 82.7MBnode 10-alpine aa67ba258e18 19 months ago 82.7MBbitbucketpipelines/bitbucket-clear-cache 3.1.1 7634a1db29b8 23 months ago 128MB
Build teardown <1s
Skipping assembly of docker cache as one is already presentSearching for files matching artifact pattern .bitbucket/pipelines/generated/pipeline/pipes/**Searching for files matching artifact pattern image.varArtifact pattern image.var matched 1 files with a total size of 30 BCompressed files matching artifact pattern image.var to 130 B in 0 secondsUploading artifact of 130 BSuccessfully uploaded artifact in 0 seconds
Is this pipe supposed to run in a separate step only? It kind of makes sense, but the documentation does not mention that.
And the follow-up:
documentation does not describe the variable "debug", though the code displays it. Setting the debug has no visible effect on the pipe output.
@AZZ hi. Thanks for your question.
According to the blog post you should use pipe like this:
pipelines:
default:
- step:
name: delete cache if changes in the build dependencies
script:
- pipe: atlassian/bitbucket-clear-cache:3.1.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USER_NAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
CACHES: ["node"]
- step:
name: build and create/reuse the cache
caches:
- node
script:
- npm install
- npm test
Examples in pipe README describes only simple use cases, so that's it's not covered there. We will extend with advanced example of usage according to your suggestion.
Also we will investigate support of DEBUG variable and notify you.
Regards, Igor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.