Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Artifact Not found

MarbleCart December 8, 2019

 

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.yaml


Second 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.war

Pattern 2: $BITBUCKET_BRANCH/*.war

Pattern 3: $BITBUCKET_BRANCH/$BITBUCKET_BUILD_NUMBER.war


Could anyone please help me out to resolve the issue. Or please let me know where I am doing wrong.



image
: openjdk:8

pipelines:
default:
- step:
name: Default build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
- mv build/libs/example-x.x.x.war $BITBUCKET_BUILD_NUMBER.war
artifacts:
- $BITBUCKET_BRANCH/**
pull-requests:
'**':
- step:
name: Build pull request
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
branches:
master:
- step:
name: Build and test master
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
development:
- step:
name: Build and test development
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

 

1 answer

1 accepted

0 votes
Answer accepted
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 8, 2019

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

MarbleCart December 8, 2019

@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)

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 8, 2019

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/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- ./gradlew test
- ./gradlew build
- mv build/libs/example-x.x.x.war build/libs/$BITBUCKET_BUILD_NUMBER.war

deploy: &deploy
trigger: manual
script:
- ./deploy $BITBUCKET_DEPLOYMENT_ENVIRONMENT build/libs/$BITBUCKET_BUILD_NUMBER.war


pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
master:
- step:
<<: *build
artifacts:
- build/libs/$BITBUCKET_BUILD_NUMBER.war
- step:
<<: *deploy
name: Deploy to test
deployment: Test
trigger: automatic
- step:
<<: *deploy
name: Deploy to staging
deployment: Staging
- step:
<<: *deploy
name: Deploy to production
deployment: 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.

Cheers,
Daniil

Like MarbleCart likes this
MarbleCart December 9, 2019

@Daniil Penkin ,

 

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

MarbleCart December 9, 2019
@Daniil Penkin ,

I have done the changes as suggested by you. Here is my updated bitbucket-pipeline.yaml without deploy configuration.


image: openjdk:8

definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
- mv build/libs/example-0.0.1.war build/libs/$BITBUCKET_BUILD_NUMBER.war

pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
master:
- step:
<<: *build
artifacts:
- build/libs/$BITBUCKET_BUILD_NUMBER.war
development:
- step:
<<: *build
Above mentioned configuration is not working when the Pull-request -> development -> development -> master.

Its creating the Artifacts but those Artifacts are empty.



But if I change the bitbucket-pipeline.yaml configuration it start creating the artifact for me:

Below are configuration for the same.
image: openjdk:8

definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build

pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
master:
- step:
<<: *build
artifacts:
- build/libs/example-0.0.1.war
development:
- step:
<<: *build

Could you please help me out where I am doing wrong or what I am missing in the configuration to get my artifact with my build_number.war ?

 

Thanks a lot

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2019

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 ?

Any step can create artifacts, there's no limit for that.

Above mentioned configuration is not working when the Pull-request -> development -> development -> master.

Yes, this is because the PR build in my original draft didn't declare any artifacts. My understanding was that you want to create artifacts in the master branch only (from your requirements list).

If you want to create an artifact in every kind of build (for pull requests, for master branch and for any other branch), simply move the declaration into the alias. An alias is just a way to avoid duplication – think of it as of a variable which is inlined when the configuration is parsed. What I mean is something like this:

image: openjdk:8

definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
# This command renames your WAR to <build_number>.war
# You might want to change it appropriately
- mv build/libs/*.war build/libs/$BITBUCKET_BUILD_NUMBER.war
artifacts:
# This exposes <build_number>.war as an artifact
- build/libs/$BITBUCKET_BUILD_NUMBER.war

pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
# Right now pipeline for `master` branch is similar to the default
# one, but since you plan to add deployment steps, I understand
# why pipeline for `master` needs an explicit declaration here.
master:
- step:
<<: *build
# It seems that you don't need specific pipeline for `development`
# branch because it is same to any other branch and hence will
# be covered by `pipelines.default`.
development:
- step:
<<: *build

 Hope this helps.

Cheers,
Daniil

MarbleCart December 9, 2019
@Daniil Penkin ,

I have changed the configuration as suggested by you. But it is not creating artifact

Updated bitbucket-pipeline.yaml

image: openjdk:8

definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
# You might want to change it appropriately
- mv build/libs/*.war build/libs/$BITBUCKET_BUILD_NUMBER.war
artifacts:
# This exposes <build_number>.war as an artifact
- build/libs/$BITBUCKET_BUILD_NUMBER.war

pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
master:
- step:
<<: *build


Capture.PNG
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2019

Hm, the artifact definition might be not resolving env variables — I'm not sure about this and can't find immediate proof.

Try changing it to use wildcard for all *.war files, like this:

artifacts:
- build/libs/*.war

If that works, my assumption was correct.

MarbleCart December 9, 2019

@Daniil Penkin ,

 

Actually it works. Still not able to figure out why it is not able to get the env variable 

$BITBUCKET_BUILD_NUMBER.war

 

image: openjdk:8

definitions:
caches:
gradlewrapper: ~/.gradle/wrapper

build: &build
name: Test and build
caches:
- gradle
- gradlewrapper
script:
- bash ./gradlew clean test
- bash ./gradlew clean build
# You might want to change it appropriately
- mv build/libs/*.war build/libs/$BITBUCKET_BUILD_NUMBER.war
artifacts:
# This exposes <build_number>.war as an artifact
- build/libs/*.war

pipelines:
default:
- step:
<<: *build
pull-requests:
'**':
- step:
<<: *build
branches:
master:
- step:
<<: *build

 

But when I am downloading and then extracting the package it contains the .war with $BITBUCKET_BUILD_NUMBER.war

 

Thanks a lot for help @Daniil Penkin .

Abhinay Sutrakar July 29, 2022

Hi @Daniil Penkin can you please help on the same.

 

I am facing the similar issue when we try to push the artifacts to target repository it is not found.

 

image: radut/openjdk-15-maven

pipelines:
  default:
    - parallel:
      - step:
          name: Triggering Test Automation
          script:
            - mkdir –p $BITBUCKET_CLONE_DIR/target
            - mvn clean install -f sps-api-automation/pom.xml -U
            - cd /opt/atlassian/pipelines/agent/build/sps-api-automation/target
            - cat site/serenity/index.html
            - mv /opt/atlassian/pipelines/agent/build/sps-api-automation/target/site/serenity/index.html /opt/atlassian/pipelines/agent/build/sps-api-automation/target
           artifacts:
            - target/**
           

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events