It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ssh command runs successfully but the pipeline does not end

I'm finalizing my pipeline on bitbucket and I'm having a problem initializing my war package.

I am starting my application through the "su root ./pacote.war" command via .sh script.

It starts successfully but the pipeline command does not understand that it has already finished the script and does not exit the deploy activity.

Do you have any tips to indicate that deploy has finished or some other command / parameter to use to initialize the application?

1 answer

0 votes

Hi Geann,

Can you try add some logging for process information into your build?

pipelines:
  default: # Or whatever you trigger your build off, such as branches/tags/pull-requests
    - step:
        artifacts:
          - process-logs.txt # Declaring that you want to keep this as an artifact
        script:
          - while true; do date && ps aux && echo "" && sleep 30; done >> process-logs.txt &
          - # The rest of your script.

I suspect you have a process hanging, which Pipelines is waiting to complete. Can you verify that none of your commands need to be manually terminated, such as your application war.

Thanks,

Phil

Hi @Philip Hodder , this is my pipeline log.

This is the question, pipeline is waiting to complete but the application already is up but i don't know how to pass this information to pipeline. So in this case i have to stop manually.

+ umask 000

+ GIT_LFS_SKIP_SMUDGE=1 git clone -n https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
Cloning into '/opt/atlassian/pipelines/agent/build'...

+ git checkout 30f8312a402619cc1f3c84f5e1036cecffc5dc09
Note: checking out '30f8312a402619cc1f3c84f5e1036cecffc5dc09'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at 30f8312a... bitbucket-pipelines.yml edited online with Bitbucket

+ git config user.name bitbucket-pipelines

+ git config user.email commits-noreply@bitbucket.org

+ git config push.default current

+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://localhost:29418/

+ git remote set-url origin http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME

+ echo ".bitbucket/pipelines/generated" >> .git/info/exclude

+ chmod 777 $BUILD_DIR

+ docker container run \
--volume=/opt/atlassian/pipelines/agent/build:/opt/atlassian/pipelines/agent/build \
--volume=/opt/atlassian/pipelines/agent/ssh:/opt/atlassian/pipelines/agent/ssh:ro \
--volume=/usr/local/bin/docker:/usr/local/bin/docker:ro \
--volume=/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes:/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes \
--volume=/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/atlassian/ssh-run:/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/atlassian/ssh-run \
--workdir=$(pwd) \
--label=org.bitbucket.pipelines.system=true \
--env=BITBUCKET_STEP_TRIGGERER_UUID="$BITBUCKET_STEP_TRIGGERER_UUID" \
--env=BITBUCKET_REPO_FULL_NAME="$BITBUCKET_REPO_FULL_NAME" \
--env=BITBUCKET_GIT_HTTP_ORIGIN="$BITBUCKET_GIT_HTTP_ORIGIN" \
--env=BITBUCKET_REPO_SLUG="$BITBUCKET_REPO_SLUG" \
--env=BITBUCKET_PROJECT_UUID="$BITBUCKET_PROJECT_UUID" \
--env=CI="$CI" \
--env=BITBUCKET_REPO_OWNER="$BITBUCKET_REPO_OWNER" \
--env=BITBUCKET_REPO_IS_PRIVATE="$BITBUCKET_REPO_IS_PRIVATE" \
--env=BITBUCKET_WORKSPACE="$BITBUCKET_WORKSPACE" \
--env=BITBUCKET_REPO_OWNER_UUID="$BITBUCKET_REPO_OWNER_UUID" \
--env=BITBUCKET_STEP_RUN_NUMBER="$BITBUCKET_STEP_RUN_NUMBER" \
--env=BITBUCKET_BUILD_NUMBER="$BITBUCKET_BUILD_NUMBER" \
--env=BITBUCKET_GIT_SSH_ORIGIN="$BITBUCKET_GIT_SSH_ORIGIN" \
--env=BITBUCKET_COMMIT="$BITBUCKET_COMMIT" \
--env=BITBUCKET_REPO_UUID="$BITBUCKET_REPO_UUID" \
--env=BITBUCKET_CLONE_DIR="$BITBUCKET_CLONE_DIR" \
--env=BITBUCKET_PROJECT_KEY="$BITBUCKET_PROJECT_KEY" \
--env=PIPELINES_JWT_TOKEN="$PIPELINES_JWT_TOKEN" \
--env=BITBUCKET_DOCKER_HOST_INTERNAL="$BITBUCKET_DOCKER_HOST_INTERNAL" \
--env=DOCKER_HOST="tcp://host.docker.internal:2375" \
--env=BITBUCKET_PIPE_SHARED_STORAGE_DIR="/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes" \
--env=BITBUCKET_PIPE_STORAGE_DIR="/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/atlassian/ssh-run" \
--env=COMMAND="/opt/onticket-dev/deploy.sh" \
--env=MODE="command" \
--env=SERVER="$FTP_HOST" \
--env=SSH_USER="$FTP_USER" \
--add-host="host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL" \
bitbucketpipelines/ssh-run:0.2.0
Unable to find image 'bitbucketpipelines/ssh-run:0.2.0' locally
0.2.0: Pulling from bitbucketpipelines/ssh-run
e7c96db7181b: Pulling fs layer
9806e1cfafda: Pulling fs layer
b83ff933fec4: Pulling fs layer
394bcfb5fb04: Pulling fs layer
394bcfb5fb04: Waiting
b83ff933fec4: Verifying Checksum
b83ff933fec4: Download complete
e7c96db7181b: Verifying Checksum
e7c96db7181b: Download complete
9806e1cfafda: Verifying Checksum
9806e1cfafda: Download complete
394bcfb5fb04: Download complete
e7c96db7181b: Pull complete
9806e1cfafda: Pull complete
b83ff933fec4: Pull complete
394bcfb5fb04: Pull complete
Digest: sha256:31076f292c2fb25bbb101e618e6108b3c32b94473e17f97cd707373df72fab1e
Status: Downloaded newer image for bitbucketpipelines/ssh-run:0.2.0
[36mINFO: Executing the pipe... [0m
[36mINFO: Using default ssh key [0m
[36mINFO: Executing command on $FTP_HOST [0m
ssh -A -tt -i /$FTP_USER/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22 $FTP_USER@$FTP_HOST /deploy.sh
[94m:: JHipster > :: Running Spring Boot 1.5.9.RELEASE ::
...
----------------------------------------------------------
Application is running! Access URLs:
Local: http://localhost:8080
External: http://127.0.0.1:8080
Profile(s): [swagger, dev]
----------------------------------------------------------

Cheers. As you mention, it looks like you're starting your application. Pipelines won't complete until the application finishes running, as it's waiting for the process to complete executing. Why do you need to start the web server in your SSH session? Could that be something you could remove and trigger the start up elsewhere, as then Pipelines won't hang waiting for the process to close. Otherwise you could also start it as a background process, rather than on the main thread of your SSH session.

Also, are there any cases where your pipeline isn't hanging, or is this a consistent issue?

About "Otherwise you could also start it as a background process, rather than on the main thread of your SSH session." How can i do it?

Also, I had the same problem and I tried to solved with '&' in the end of the command to run the process in the background and redirected the stdout and stderr using 1>>"logfile.log" 2>&1 .

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,052 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you