I’m trying to deploy a python package from our bitbucket pipeline to our nexus repository manager. Using the pipe: sonatype/nexus-repository-publish:0.0.1.
I’ve tried to use a filename with wildcard: “*.tar.gz”, but the pipe gives a file not found error. Can’t we use wildcard? The tar.gz filename will change for every release as it includes a versionnumber. What can I do about this?
If I use the complete filename, no error is reported, but the file is also not deployed to the repository. There is also no output at all so I don’t know if I have done anything wrong or not.
I have replicated this issue. It appears that Bitbucket pipelines don’t perform any file globbing or expansion at all. The value for FILENAME is simple passed directly into the underlying Groovy script.
It would be possible to manually do the globbing, however I will point out that you still will need to pass in the specific version you are deploying to the ATTRIBUTES parameter. In the example in the readme that looks like:
I would expect that since this is needed anyways that it may be easier to just compute the version in the pipeline ahead of time and pass it in for both spots needed. I’m not super familiar with Bitbucket Pipelines but most CI systems I know would have the capacity for this.
This link has some pointers on how to get the current version.
Hi. Thanks for anwering. Your suggested workflow however doesn’t comply to how we (want) to do it. We now use twine to upload which works perfectly and uses the version from setup.py.
I’m not a Bitbucket Pipelines user at all, but was able to make this work. I think you can adapt it to your python workflow. I’m using Maven to export the version number to a file but that can be any command.
image: maven:3.3.9
pipelines:
default:
- step:
name: build
caches:
- maven
script: # Modify the commands below to build your repository.
- mvn -B verify # -B batch mode makes Maven less verbose
- MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- echo $MVN_VERSION
- echo "export MVN_VERSION=$MVN_VERSION" >> set_env.sh
artifacts:
- target/**
- set_env.sh
- step:
# set NEXUS_USERNAME and NEXUS_PASSWORD as environment variables
name: Deploy to Nexus Repository Manager
deployment: test # set to test, staging or production
trigger: manual # do not build automatically
script:
- cat set_env.sh
- source set_env.sh
- echo $MVN_VERSION
- pipe: sonatype/nexus-repository-publish:0.0.1
variables:
FILENAME: "target/example-$MVN_VERSION.jar"
ATTRIBUTES: "-CgroupId=org.sonatype -CartifactId=example -Cversion=$MVN_VERSION -Aextension=jar"
USERNAME: "$NEXUS_USERNAME"
PASSWORD: "$NEXUS_PASSWORD"
SERVER_URL: "$NEXUS_SERVER_URL"
REPOSITORY: "test-repo"
FORMAT: "maven2"