Search code examples
kubernetessonarqubebitbucketbitbucket-pipelines

Bitbucket pipeline runner issue


I have a bitbukcet pipeline runner in my kubernetes cluster

kubectl get po -A --watch
NAMESPACE              NAME                                            READY   STATUS    RESTARTS        AGE
default                runner-01-26kgg                                 2/2     Running   0               44h

These containers have the hostname as

/ # hostname 
runner-01-26kgg

But when I check the hostname from pipeline its showing the hostname as

+ echo "Executing on runner: ${BITBUCKET_PIPE_RUN_ON}"
echo "Runner container hostname: $(hostname)"
Executing on runner: 
Runner container hostname: 9ce8de576a8c

and im not sure which container its showing.

My pipeline is below

image: maven:3.3.9

pipelines:
  branches:
    '{master}':
      - step:
          name: Build and Analyze
          runs-on:
            - self.hosted
            - linux
          script:
            - |
              echo "Executing on runner: ${BITBUCKET_PIPE_RUN_ON}"
              echo "Runner container hostname: $(hostname)"
              echo "Environment variables:"
              printenv

Runners are configured with labels self.hosted,linux and are active in bitbucket. Can I get a help to run the job in same runner.

image: maven:3.3.9

pipelines: branches: '{master}': - step: name: Build and Analyze runs-on: - self.hosted - linux script: - | echo "Executing on runner: ${BITBUCKET_PIPE_RUN_ON}" echo "Runner container hostname: $(hostname)" echo "Environment variables:" printenv


Solution

  • Pipelines run in docker containers spawned in the runner, not directly in the runner. That's why $(hostname) evals to a container ID.

    Also you made up the $BITBUCKET_PIPE_RUN_ON variable so it is empty. See https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ for the existing variables that can be used in scripts.

              runs-on:
                - self.hosted
                - linux
    

    this should be enough so that the step runs on your self-hosted runner. Maybe I don't understand your question, sorry.