2017-08-02 1 views
1

のためのRSAホストキーを追加しました:のBitbucketパイプライン警告:永続的に私は基本的に、私はbashスクリプトを持って、私のビットバケットパイプラインに自動化されたタグの作成 を統合しようとしているIPアドレス

#!/bin/bash 

# retrieve branch name 
BRANCH_NAME=$(git branch | sed -n '/\* /s///p') 

# remove prefix release 
REGEXP_RELEASE="release\/" 
VERSION_BRANCH=$(echo "$BRANCH_NAME" | sed "s/$REGEXP_RELEASE//") 

echo "Current version branch is $VERSION_BRANCH" 

# retrieve the last commit on the branch 
VERSION=$(git describe --tags --match=$VERSION_BRANCH* --abbrev=0) 

# split into array 
VERSION_BITS=(${VERSION//./ }) 

#get number parts and increase last one by 1 
VNUM1=${VERSION_BITS[0]} 
VNUM2=${VERSION_BITS[1]} 
VNUM3=${VERSION_BITS[2]} 
VNUM3=$((VNUM3+1)) 

#create new tag 
NEW_TAG="$VNUM1.$VNUM2.$VNUM3" 

echo "Updating $VERSION to $NEW_TAG" 

#get current hash and see if it already has a tag 
GIT_COMMIT=`git rev-parse HEAD` 
NEEDS_TAG=`git describe --contains $GIT_COMMIT` 

#only tag if no tag already (would be better if the git describe command above could have a silent option) 
if [ -z "$NEEDS_TAG" ]; then 
    echo "Tagged with $NEW_TAG (Ignoring fatal:cannot describe - this means commit is untagged) " 
    git tag $NEW_TAG 
    git push --tags 
else 
    echo "Already a tag on this commit" 
fi 

その後、私のパイプライン:

パイプラインは、タグをプッシュしようとしたとき
# This is a sample build configuration for Java (Maven). 
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples. 
# Only use spaces to indent your .yml configuration. 
# ----- 
# You can specify a custom docker image from Docker Hub as your build environment. 
image: maven:3.3.9 

pipelines: 
    default: 
    - step: 
     caches: 
      - maven 
     script: # Modify the commands below to build your repository. 
      - mvn clean package -Denv=uat 
    branches: 
    master: 
     - step: 
      caches: 
      - maven 
      script: # Modify the commands below to build your repository. 
      - mvn clean package -Denv=uat 
      - chmod +x tag.sh 
      - ./tag.sh 

は、しかし、私はエラーを取得しています:

./tag.sh<1s 
+ ./tag.sh 
Current version branch is master 
Updating master-1.0.2 to master-1.0.3fatal: cannot describe '493bf0b1aef120879af57e25d63dde24ad0c7de2' 
Tagged with master-1.0.3 (Ignoring fatal:cannot describe - this means commit is untagged) 

Warning: Permanently added the RSA host key for IP address '104.192.143.3' to the list of known hosts. 
Permission denied (publickey). 
fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists. 

私が理解していないのは、なぜこの問題が発生しているのか、それを解決する方法です。 私が読んでhttps://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html しかし、私は最初に私はパイプラインのリモートへのアクセス権を持っていないとして理解していない。 IPの変更に伴い、既知のホストとして追加することはできません。 ビルドを実行しているレポにプッシュする方法はありますか?

タグが見つかってレポがクローンされたので、私は確かにプッシュを行うことができます。

+0

SSH鍵はすでに追加されていますが、既知のホストファイルは更新されていません –

+0

正直言って私は知らない。私はレポが複製されたログを見ただけです。ビルドにはrepoが必要です:)と私はプッシュ以外のコマンドを実行することができます – Geoffrey

+0

そして、あなたはbitbucketだけにプッシュしていますか? –

答えて

0

REPOには公開SSHキーへの参照が含まれていないか、パイプラインが実行されているDockerイメージには、そのrepoがauthorized_keysファイルで認識できないSSHキーが含まれています。

ていることを確認してください: は - ドッカーのBitbucketパイプライン画像上のSSHキーが存在し、 正しいです - 右の公開鍵がアクセスを許可されることを保証するために、ビットバケットリポジトリにアクセスすることを許可されているキーを確認してください。

このエラーは通常、SSHキーの不一致の問題です。私はそれを何度も繰り返してきました。

その他の事項:- 公開鍵を設定した場合は、CATコマンド(nixで実行している場合)を使用していることを確認してください。 - 他の場所からコピー/ペーストした場合、公開鍵が確認されていることを確認してください

関連する問題