{"action":"opened","issue":{"url":"https://api.github.com/repos/mlabouardy/nexus-cli/issues/15","repository_url":"https://api.github.com/repos/mlabouardy/nexus-cli","labels_url":"https://api.github.com/repos/mlabouardy/nexus-cli/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/mlabouardy/nexus-cli/issues/15/comments","events_url":"https://api.github.com/repos/mlabouardy/nexus-cli/issues/15/events","html_url":"https://github.com/mlabouardy/nexus-cli/issues/15","id":313511385,"number":15,"title":"Multiple executions give different output","user":{"login":"AndresCidoncha","id":8897971,"avatar_url":"https://avatars3.githubusercontent.com/u/8897971?v=4","gravatar_id":"","url":"https://api.github.com/users/AndresCidoncha","html_url":"https://github.com/AndresCidoncha","followers_url":"https://api.github.com/users/AndresCidoncha/followers","following_url":"https://api.github.com/users/AndresCidoncha/following{/other_user}","gists_url":"https://api.github.com/users/AndresCidoncha/gists{/gist_id}","starred_url":"https://api.github.com/users/AndresCidoncha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndresCidoncha/subscriptions","organizations_url":"https://api.github.com/users/AndresCidoncha/orgs","repos_url":"https://api.github.com/users/AndresCidoncha/repos","events_url":"https://api.github.com/users/AndresCidoncha/events{/privacy}","received_events_url":"https://api.github.com/users/AndresCidoncha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-11T22:35:09Z","updated_at":"2018-04-11T22:35:09Z","closed_at":null,"author_association":"NONE","body":"I'm using the nexus-cli in a script to allow me using regex in tag and delete all except last x tags for this regex.\r\n\r\nMy script looks like:\r\n\r\n~~~\r\nimages=($(./nexus-cli image ls | grep -v \"Total images:\"))\r\ntag=\"functional_([0-9])+\"\r\nkeep=5\r\n\r\nwhile [[ $# > 0 ]]; do\r\n  case $1 in\r\n    -t|--tag)\r\n      shift\r\n      tag=$1\r\n      ;;\r\n    -n|--number)\r\n      shift\r\n      keep=$1\r\n      ;;\r\n    *)\r\n      usage\r\n      ;;\r\n  esac\r\n  shift\r\ndone\r\n\r\necho \"Cleaning tags for ${#images[@]} images\"\r\nfor image in ${images[@]}; do\r\n  echo \"Tags for $image\"\r\n  tags=($(./nexus-cli image tags -n $image | egrep \"$tag\" | sort -k 2n -t'_'))\r\n  n_delete=$((${#tags[@]}-$keep))\r\n  echo \"Found ${#tags[@]} tags\"\r\n  if [ $n_delete -gt 0 ]; then\r\n    echo \"Going to delete $n_delete tags\"\r\n    for tag in ${tags[@]:0:$n_delete}; do\r\n      ./nexus-cli image delete -n $image -t $tag\r\n    done\r\n  else\r\n    echo \"Not enough tags (${#tags[@]})\"\r\n  fi\r\ndone\r\n~~~\r\n\r\nMy problem is that using the default parameters (for example), images that have multiple `functional_x` tags are reporting that have 0 images with tag that fit the regex.\r\n\r\nIn script:\r\n\r\n~~~\r\nTags for influxdb_configure\r\nFound 0 tags\r\nNot enough tags (0)\r\n~~~\r\n\r\nIn shell:\r\n\r\n~~~\r\nroot@nexus-dev:/home/ops# ./nexus-cli image tags -n influxdb_configure | grep functional\r\nfunctional_1\r\nfunctional_2\r\nfunctional_3\r\nfunctional_latest\r\n~~~\r\n\r\nWhich can be the problem?\r\n\r\n"}}
{"actor":{"display_login":"AndresCidoncha"}}