First Question : Whether it is possible to create the artifact for the default branch or not ? When master branch having different step. Please have a look in below bitbucket-pipeline.yamlSecond Question :Trying to achieve:- Trying to create the artifact for the default branch ? Not sure whether possible or not.Issue facing:Created the artifacts section but it is showing "no artifacts available"Tried Out following things:I have tried different patterns to get artifacts.Please replace thees patterns in artifacts:Pattern 1: $BITBUCKET_BUILD_NUMBER.warPattern 2: $BITBUCKET_BRANCH/*.warPattern 3: $BITBUCKET_BRANCH/$BITBUCKET_BUILD_NUMBER.warCould anyone please help me out to resolve the issue. Or please let me know where I am doing wrong.image: openjdk:8pipelines:default: - step:name: Default buildcaches: - gradle - gradlewrapperscript: - bash ./gradlew clean test - bash ./gradlew clean build - mv build/libs/example-x.x.x.war $BITBUCKET_BUILD_NUMBER.warartifacts: - $BITBUCKET_BRANCH/**pull-requests:'**': - step:name: Build pull requestcaches: - gradle - gradlewrapperscript: - bash ./gradlew clean test - bash ./gradlew clean buildbranches:master: - step:name: Build and test mastercaches: - gradle - gradlewrapperscript: - bash ./gradlew clean test - bash ./gradlew clean builddevelopment: - step:name: Build and test developmentcaches: - gradle - gradlewrapperscript: - bash ./gradlew clean test - bash ./gradlew clean builddefinitions:caches:gradlewrapper: ~/.gradle/wrapper
Hello @MarbleCart,
Welcome to the Community!
Did I get it right that you're trying to build artifacts for master branch? If so, they're not created with your current build config because you have an explicit configuration for branch master which doesn't define any artifacts. As in, default pipeline is not being triggered for changes in master branch (as well as changes in development branch since it has an explicit pipeline too).
As for the artifact name, Pattern 1 would work at the moment since you're moving your war into $BITBUCKET_BUILD_NUMBER.war in the last command of your script. But again, it would work only on a branch which is not called master or development.
As a side note, I can see quite a lot of duplication in your pipelines definition which makes it harder to maintain the configuration. You might benefit from using anchors.
If you describe your desired build setup, I might be able to suggest a script for that.
Hope this helps.
Cheers,Daniil
@Daniil Penkin ,
So, does it mean I can't make the artifact for the default branch if I defined the master branch explicitly ?
What I want to my build pipeline looks like is :
1. I want build all my branch with pattern or without pattern.
2. Need build for the pull request raised by the person.
3. All the pull request merge to development branch and need the build for development branch also after merging of pull request.
4. Only need to deploy the master branch to my production once development branch is merged with master.
5. Once the development is merged with master:
1. Test and build
2. Create an Artifact and also deploy to S3 bucket ( Automatic )
3. (Next Step) Automatic trigger the deployment to "test" environment.
6. Once everything stable in the test environment trigger the deployment to staging by pulling the latest build from the bitbucket artifact if available or AWS S3 (because it is only available for 7 days). (Manual trigger) deployment
7. Finally to production ( repeat the step 6) (Deploying to AWS Beanstalk) (I can use bitbucket pipes)
So, does it mean I can't make the artifact for the default branch if I defined the master branch explicitly?
Hm, I think there's some misunderstanding here. So pipelines.default defines a pipeline that is triggered by default, as in when there's no more specific pipeline that matches an event. So I'm not sure what you meant by default branch in your question. If you define a pipeline specific for a branch, default pipeline won't be triggered. Does it make sense?
Now, to your scenario. Here's what I drafted in 5 minutes and I think is meeting all your requirements — not saying it's 100% correct (that is, please verify it), but it's probably at least a good thing to start with:
definitions:caches:gradlewrapper: ~/.gradle/wrapperbuild: &build name: Test and buildcaches: - gradle - gradlewrapperscript: - ./gradlew test - ./gradlew build - mv build/libs/example-x.x.x.war build/libs/$BITBUCKET_BUILD_NUMBER.wardeploy: &deploy trigger: manualscript: - ./deploy $BITBUCKET_DEPLOYMENT_ENVIRONMENT build/libs/$BITBUCKET_BUILD_NUMBER.warpipelines:default: - step:<<: *build pull-requests:'**': - step:<<: *build branches:master: - step:<<: *build artifacts: - build/libs/$BITBUCKET_BUILD_NUMBER.war - step:<<: *deploy name: Deploy to testdeployment: Testtrigger: automatic - step:<<: *deploy name: Deploy to stagingdeployment: Staging - step:<<: *deploy name: Deploy to productiondeployment: Production
Basically, build step for branches and PRs is same, but the one for master also declares artifacts which are then used by deploy steps.
Deploy steps in turn are similar too, the difference is in the trigger type and name.
Note that you'll need to set up Test, Staging and Production deployments in your repository.
Hope this helps. Let me know if you have any questions.
Your default and mine default reference are same.
What I intended to ask is that If in the bitbucket-pipeline.yaml we have define "pipelines.default" and "pipelines.branches.master" both and I want to create the artifact of "pipelines.default". Is it possible ?
Hope so I have asked now this question properly if not please let me know I will try to re-frame my question.
Thank you
It looks like you're new here. Sign in or register to get started.