From 84d40986bf74fb8c4e3abb92ecbb10ff64dbb076 Mon Sep 17 00:00:00 2001 From: thespad Date: Thu, 9 May 2024 17:34:45 +0100 Subject: [PATCH] Revive image --- .editorconfig | 2 +- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/issue.bug.yml | 74 ++- .github/ISSUE_TEMPLATE/issue.feature.yml | 33 +- .github/PULL_REQUEST_TEMPLATE.md | 4 - .github/workflows/call_issue_pr_tracker.yml | 16 + .github/workflows/call_issues_cron.yml | 13 + .github/workflows/external_trigger.yml | 104 ++++ .../workflows/external_trigger_scheduler.yml | 45 ++ .github/workflows/greetings.yml | 2 +- .github/workflows/package_trigger.yml | 42 ++ .../workflows/package_trigger_scheduler.yml | 50 ++ .github/workflows/permissions.yml | 10 + Dockerfile | 110 ++-- Dockerfile.aarch64 | 110 ++-- Dockerfile.armhf | 124 ---- Jenkinsfile | 585 +++++++++--------- README.md | 184 +++--- jenkins-vars.yml | 9 +- readme-vars.yml | 71 +-- root/donate.txt | 2 +- root/etc/cont-init.d/99-deprecation | 19 - .../s6-overlay/s6-rc.d/init-nzbget-config/run | 5 +- .../s6-rc.d/init-nzbget-config/type | 2 +- .../s6-overlay/s6-rc.d/init-nzbget-config/up | 2 +- .../dependencies.d/legacy-services | 0 .../s6-rc.d/init-nzbget-deprecation/run | 20 - .../s6-rc.d/init-nzbget-deprecation/type | 1 - .../s6-rc.d/init-nzbget-deprecation/up | 1 - root/etc/s6-overlay/s6-rc.d/svc-nzbget/run | 6 +- root/etc/s6-overlay/s6-rc.d/svc-nzbget/type | 2 +- .../user2/contents.d/init-nzbget-deprecation | 0 32 files changed, 907 insertions(+), 743 deletions(-) create mode 100644 .github/workflows/call_issue_pr_tracker.yml create mode 100644 .github/workflows/call_issues_cron.yml create mode 100644 .github/workflows/external_trigger.yml create mode 100644 .github/workflows/external_trigger_scheduler.yml create mode 100644 .github/workflows/package_trigger.yml create mode 100644 .github/workflows/package_trigger_scheduler.yml create mode 100644 .github/workflows/permissions.yml delete mode 100644 Dockerfile.armhf delete mode 100755 root/etc/cont-init.d/99-deprecation delete mode 100644 root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/dependencies.d/legacy-services delete mode 100755 root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/run delete mode 100644 root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/type delete mode 100644 root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/up delete mode 100644 root/etc/s6-overlay/s6-rc.d/user2/contents.d/init-nzbget-deprecation diff --git a/.editorconfig b/.editorconfig index a92f7df..5f150f3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,6 +15,6 @@ trim_trailing_whitespace = false indent_style = space indent_size = 2 -[{**.sh,root/etc/cont-init.d/**,root/etc/services.d/**}] +[{**.sh,root/etc/s6-overlay/s6-rc.d/**,root/etc/cont-init.d/**,root/etc/services.d/**}] indent_style = space indent_size = 4 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 4be2457..491e327 100755 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ github: linuxserver open_collective: linuxserver -custom: ["https://nzbget.net/donate",] +custom: ["https://nzbget.com/donate/",] diff --git a/.github/ISSUE_TEMPLATE/issue.bug.yml b/.github/ISSUE_TEMPLATE/issue.bug.yml index 8fa89e4..bd5567b 100755 --- a/.github/ISSUE_TEMPLATE/issue.bug.yml +++ b/.github/ISSUE_TEMPLATE/issue.bug.yml @@ -4,11 +4,73 @@ description: Create a report to help us improve title: "[BUG] " labels: [Bug] body: - - type: markdown + - type: checkboxes attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists for the bug you encountered. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Current Behavior + description: Tell us what happens instead of the expected behavior. + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: Tell us what should happen. + validations: + required: false + - type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: true + - type: textarea + attributes: + label: Environment + description: | + examples: + - **OS**: Ubuntu 20.04 + - **How docker service was installed**: distro's packagemanager value: | - # DEPRECATION NOTICE - - This image is deprecated. We will not offer support for this image and it will not be updated. - - nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd + - OS: + - How docker service was installed: + render: markdown + validations: + required: false + - type: dropdown + attributes: + label: CPU architecture + options: + - x86-64 + - arm64 + validations: + required: true + - type: textarea + attributes: + label: Docker creation + description: | + Command used to create docker container + Provide your docker create/run command or compose yaml snippet, or a screenshot of settings if using a gui to create the container + render: bash + validations: + required: true + - type: textarea + attributes: + description: | + Provide a full docker log, output of "docker logs nzbget" + label: Container logs + placeholder: | + Output of `docker logs nzbget` + render: bash + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/issue.feature.yml b/.github/ISSUE_TEMPLATE/issue.feature.yml index 75bbdad..099dcdb 100755 --- a/.github/ISSUE_TEMPLATE/issue.feature.yml +++ b/.github/ISSUE_TEMPLATE/issue.feature.yml @@ -4,11 +4,28 @@ description: Suggest an idea for this project title: "[FEAT] <title>" labels: [enhancement] body: - - type: markdown - attributes: - value: | - # DEPRECATION NOTICE - - This image is deprecated. We will not offer support for this image and it will not be updated. - - nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd + - type: checkboxes + attributes: + label: Is this a new feature request? + description: Please search to see if a feature request already exists. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Wanted change + description: Tell us what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Reason for change + description: Justify your request, why do you want it, what is the benefit. + validations: + required: true + - type: textarea + attributes: + label: Proposed code change + description: Do you have a potential code change in mind? + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4651a88..5859fe9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,3 @@ -# DEPRECATION NOTICE - -This image is deprecated. We will not offer support for this image and it will not be updated. -nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd <!--- Provide a general summary of your changes in the Title above --> [linuxserverurl]: https://linuxserver.io diff --git a/.github/workflows/call_issue_pr_tracker.yml b/.github/workflows/call_issue_pr_tracker.yml new file mode 100644 index 0000000..2c30784 --- /dev/null +++ b/.github/workflows/call_issue_pr_tracker.yml @@ -0,0 +1,16 @@ +name: Issue & PR Tracker + +on: + issues: + types: [opened,reopened,labeled,unlabeled,closed] + pull_request_target: + types: [opened,reopened,review_requested,review_request_removed,labeled,unlabeled,closed] + pull_request_review: + types: [submitted,edited,dismissed] + +jobs: + manage-project: + permissions: + issues: write + uses: linuxserver/github-workflows/.github/workflows/issue-pr-tracker.yml@v1 + secrets: inherit diff --git a/.github/workflows/call_issues_cron.yml b/.github/workflows/call_issues_cron.yml new file mode 100644 index 0000000..89dd19c --- /dev/null +++ b/.github/workflows/call_issues_cron.yml @@ -0,0 +1,13 @@ +name: Mark stale issues and pull requests +on: + schedule: + - cron: '31 7 * * *' + workflow_dispatch: + +jobs: + stale: + permissions: + issues: write + pull-requests: write + uses: linuxserver/github-workflows/.github/workflows/issues-cron.yml@v1 + secrets: inherit diff --git a/.github/workflows/external_trigger.yml b/.github/workflows/external_trigger.yml new file mode 100644 index 0000000..74d093f --- /dev/null +++ b/.github/workflows/external_trigger.yml @@ -0,0 +1,104 @@ +name: External Trigger Main + +on: + workflow_dispatch: + +jobs: + external-trigger-master: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + + - name: External Trigger + if: github.ref == 'refs/heads/master' + run: | + if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_NZBGET_MASTER }}" ]; then + echo "**** Github secret PAUSE_EXTERNAL_TRIGGER_NZBGET_MASTER is set; skipping trigger. ****" + echo "Github secret \`PAUSE_EXTERNAL_TRIGGER_NZBGET_MASTER\` is set; skipping trigger." >> $GITHUB_STEP_SUMMARY + exit 0 + fi + echo "**** External trigger running off of master branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_NZBGET_MASTER\". ****" + echo "External trigger running off of master branch. To disable this trigger, set a Github secret named \`PAUSE_EXTERNAL_TRIGGER_NZBGET_MASTER\`" >> $GITHUB_STEP_SUMMARY + echo "**** Retrieving external version ****" + EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/nzbgetcom/nzbget/releases/latest" | jq -r '. | .tag_name') + if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then + echo "**** Can't retrieve external version, exiting ****" + FAILURE_REASON="Can't retrieve external version for nzbget branch master" + GHA_TRIGGER_URL="https://github.com/linuxserver/docker-nzbget/actions/runs/${{ github.run_id }}" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680, + "description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n**Trigger URL:** '"${GHA_TRIGGER_URL}"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + exit 1 + fi + EXT_RELEASE=$(echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g') + echo "**** External version: ${EXT_RELEASE} ****" + echo "External version: ${EXT_RELEASE}" >> $GITHUB_STEP_SUMMARY + echo "**** Retrieving last pushed version ****" + image="linuxserver/nzbget" + tag="latest" + token=$(curl -sX GET \ + "https://ghcr.io/token?scope=repository%3Alinuxserver%2Fnzbget%3Apull" \ + | jq -r '.token') + multidigest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${tag}" \ + | jq -r 'first(.manifests[].digest)') + digest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${multidigest}" \ + | jq -r '.config.digest') + image_info=$(curl -sL \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/blobs/${digest}") + if [[ $(echo $image_info | jq -r '.container_config') == "null" ]]; then + image_info=$(echo $image_info | jq -r '.config') + else + image_info=$(echo $image_info | jq -r '.container_config') + fi + IMAGE_RELEASE=$(echo ${image_info} | jq -r '.Labels.build_version' | awk '{print $3}') + IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-ls' '{print $1}') + if [ -z "${IMAGE_VERSION}" ]; then + echo "**** Can't retrieve last pushed version, exiting ****" + FAILURE_REASON="Can't retrieve last pushed version for nzbget tag latest" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680, + "description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + exit 1 + fi + echo "**** Last pushed version: ${IMAGE_VERSION} ****" + echo "Last pushed version: ${IMAGE_VERSION}" >> $GITHUB_STEP_SUMMARY + if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then + echo "**** Version ${EXT_RELEASE} already pushed, exiting ****" + echo "Version ${EXT_RELEASE} already pushed, exiting" >> $GITHUB_STEP_SUMMARY + exit 0 + elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-nzbget/job/master/lastBuild/api/json | jq -r '.building') == "true" ]; then + echo "**** New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting ****" + echo "New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY + exit 0 + else + echo "**** New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build ****" + echo "New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build" >> $GITHUB_STEP_SUMMARY + response=$(curl -iX POST \ + https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-nzbget/job/master/buildWithParameters?PACKAGE_CHECK=false \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") + echo "**** Jenkins job queue url: ${response%$'\r'} ****" + echo "**** Sleeping 10 seconds until job starts ****" + sleep 10 + buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') + buildurl="${buildurl%$'\r'}" + echo "**** Jenkins job build url: ${buildurl} ****" + echo "Jenkins job build url: ${buildurl}" >> $GITHUB_STEP_SUMMARY + echo "**** Attempting to change the Jenkins job description ****" + curl -iX POST \ + "${buildurl}submitDescription" \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ + --data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + --data-urlencode "Submit=Submit" + echo "**** Notifying Discord ****" + TRIGGER_REASON="A version change was detected for nzbget tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, + "description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} + fi diff --git a/.github/workflows/external_trigger_scheduler.yml b/.github/workflows/external_trigger_scheduler.yml new file mode 100644 index 0000000..9658680 --- /dev/null +++ b/.github/workflows/external_trigger_scheduler.yml @@ -0,0 +1,45 @@ +name: External Trigger Scheduler + +on: + schedule: + - cron: '12 * * * *' + workflow_dispatch: + +jobs: + external-trigger-scheduler: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + + - name: External Trigger Scheduler + run: | + echo "**** Branches found: ****" + git for-each-ref --format='%(refname:short)' refs/remotes + for br in $(git for-each-ref --format='%(refname:short)' refs/remotes) + do + br=$(echo "$br" | sed 's|origin/||g') + echo "**** Evaluating branch ${br} ****" + ls_jenkins_vars=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-nzbget/${br}/jenkins-vars.yml) + ls_branch=$(echo "${ls_jenkins_vars}" | yq -r '.ls_branch') + ls_trigger=$(echo "${ls_jenkins_vars}" | yq -r '.external_type') + if [[ "${br}" == "${ls_branch}" ]] && [[ "${ls_trigger}" != "os" ]]; then + echo "**** Branch ${br} appears to be live and trigger is not os; checking workflow. ****" + if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-nzbget/${br}/.github/workflows/external_trigger.yml > /dev/null 2>&1; then + echo "**** Workflow exists. Triggering external trigger workflow for branch ${br} ****." + echo "Triggering external trigger workflow for branch ${br}" >> $GITHUB_STEP_SUMMARY + curl -iX POST \ + -H "Authorization: token ${{ secrets.CR_PAT }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -d "{\"ref\":\"refs/heads/${br}\"}" \ + https://api.github.com/repos/linuxserver/docker-nzbget/actions/workflows/external_trigger.yml/dispatches + else + echo "**** Workflow doesn't exist; skipping trigger. ****" + echo "Skipping branch ${br} due to no external trigger workflow present." >> $GITHUB_STEP_SUMMARY + fi + else + echo "**** ${br} is either a dev branch, or has no external version; skipping trigger. ****" + echo "Skipping branch ${br} due to being detected as dev branch or having no external version." >> $GITHUB_STEP_SUMMARY + fi + done diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 6e08619..d01eb12 100755 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -8,6 +8,6 @@ jobs: steps: - uses: actions/first-interaction@v1 with: - issue-message: 'Thanks for opening your first issue here! Be sure to follow the [bug](https://github.com/linuxserver/docker-nzbget/blob/master/.github/ISSUE_TEMPLATE/issue.bug.yml) or [feature](https://github.com/linuxserver/docker-nzbget/blob/master/.github/ISSUE_TEMPLATE/issue.feature.yml) issue templates!' + issue-message: 'Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.' pr-message: 'Thanks for opening this pull request! Be sure to follow the [pull request template](https://github.com/linuxserver/docker-nzbget/blob/master/.github/PULL_REQUEST_TEMPLATE.md)!' repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/package_trigger.yml b/.github/workflows/package_trigger.yml new file mode 100644 index 0000000..c9e1c3c --- /dev/null +++ b/.github/workflows/package_trigger.yml @@ -0,0 +1,42 @@ +name: Package Trigger Main + +on: + workflow_dispatch: + +jobs: + package-trigger-master: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + + - name: Package Trigger + if: github.ref == 'refs/heads/master' + run: | + if [ -n "${{ secrets.PAUSE_PACKAGE_TRIGGER_NZBGET_MASTER }}" ]; then + echo "**** Github secret PAUSE_PACKAGE_TRIGGER_NZBGET_MASTER is set; skipping trigger. ****" + echo "Github secret \`PAUSE_PACKAGE_TRIGGER_NZBGET_MASTER\` is set; skipping trigger." >> $GITHUB_STEP_SUMMARY + exit 0 + fi + if [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-nzbget/job/master/lastBuild/api/json | jq -r '.building') == "true" ]; then + echo "**** There already seems to be an active build on Jenkins; skipping package trigger ****" + echo "There already seems to be an active build on Jenkins; skipping package trigger" >> $GITHUB_STEP_SUMMARY + exit 0 + fi + echo "**** Package trigger running off of master branch. To disable, set a Github secret named \"PAUSE_PACKAGE_TRIGGER_NZBGET_MASTER\". ****" + echo "Package trigger running off of master branch. To disable, set a Github secret named \`PAUSE_PACKAGE_TRIGGER_NZBGET_MASTER\`" >> $GITHUB_STEP_SUMMARY + response=$(curl -iX POST \ + https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-nzbget/job/master/buildWithParameters?PACKAGE_CHECK=true \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|") + echo "**** Jenkins job queue url: ${response%$'\r'} ****" + echo "**** Sleeping 10 seconds until job starts ****" + sleep 10 + buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url') + buildurl="${buildurl%$'\r'}" + echo "**** Jenkins job build url: ${buildurl} ****" + echo "Jenkins job build url: ${buildurl}" >> $GITHUB_STEP_SUMMARY + echo "**** Attempting to change the Jenkins job description ****" + curl -iX POST \ + "${buildurl}submitDescription" \ + --user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \ + --data-urlencode "description=GHA package trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + --data-urlencode "Submit=Submit" diff --git a/.github/workflows/package_trigger_scheduler.yml b/.github/workflows/package_trigger_scheduler.yml new file mode 100644 index 0000000..fd51b57 --- /dev/null +++ b/.github/workflows/package_trigger_scheduler.yml @@ -0,0 +1,50 @@ +name: Package Trigger Scheduler + +on: + schedule: + - cron: '9 15 * * 5' + workflow_dispatch: + +jobs: + package-trigger-scheduler: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: '0' + + - name: Package Trigger Scheduler + run: | + echo "**** Branches found: ****" + git for-each-ref --format='%(refname:short)' refs/remotes + for br in $(git for-each-ref --format='%(refname:short)' refs/remotes) + do + br=$(echo "$br" | sed 's|origin/||g') + echo "**** Evaluating branch ${br} ****" + ls_branch=$(curl -sX GET https://raw.githubusercontent.com/linuxserver/docker-nzbget/${br}/jenkins-vars.yml | yq -r '.ls_branch') + if [ "${br}" == "${ls_branch}" ]; then + echo "**** Branch ${br} appears to be live; checking workflow. ****" + if curl -sfX GET https://raw.githubusercontent.com/linuxserver/docker-nzbget/${br}/.github/workflows/package_trigger.yml > /dev/null 2>&1; then + echo "**** Workflow exists. Triggering package trigger workflow for branch ${br}. ****" + echo "Triggering package trigger workflow for branch ${br}" >> $GITHUB_STEP_SUMMARY + triggered_branches="${triggered_branches}${br} " + curl -iX POST \ + -H "Authorization: token ${{ secrets.CR_PAT }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -d "{\"ref\":\"refs/heads/${br}\"}" \ + https://api.github.com/repos/linuxserver/docker-nzbget/actions/workflows/package_trigger.yml/dispatches + sleep 30 + else + echo "**** Workflow doesn't exist; skipping trigger. ****" + echo "Skipping branch ${br} due to no package trigger workflow present." >> $GITHUB_STEP_SUMMARY + fi + else + echo "**** ${br} appears to be a dev branch; skipping trigger. ****" + echo "Skipping branch ${br} due to being detected as dev branch." >> $GITHUB_STEP_SUMMARY + fi + done + echo "**** Package check build(s) triggered for branch(es): ${triggered_branches} ****" + echo "**** Notifying Discord ****" + curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, + "description": "**Package Check Build(s) Triggered for nzbget** \n**Branch(es):** '"${triggered_branches}"' \n**Build URL:** '"https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-nzbget/activity/"' \n"}], + "username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/permissions.yml b/.github/workflows/permissions.yml new file mode 100644 index 0000000..1447bc5 --- /dev/null +++ b/.github/workflows/permissions.yml @@ -0,0 +1,10 @@ +name: Permission check +on: + pull_request_target: + paths: + - '**/run' + - '**/finish' + - '**/check' +jobs: + permission_check: + uses: linuxserver/github-workflows/.github/workflows/init-svc-executable-permissions.yml@v1 diff --git a/Dockerfile b/Dockerfile index 5022e46..069b874 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ -# Buildstage -FROM ghcr.io/linuxserver/baseimage-alpine:3.16 as buildstage +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/unrar:latest as unrar + +FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage # set NZBGET version ARG NZBGET_RELEASE @@ -7,55 +10,55 @@ ARG NZBGET_RELEASE RUN \ echo "**** install build packages ****" && \ apk add \ - g++ \ - gcc \ + boost-dev \ + build-base \ + cmake \ git \ libxml2-dev \ libxslt-dev \ - make \ ncurses-dev \ openssl-dev && \ echo "**** build nzbget ****" && \ if [ -z ${NZBGET_RELEASE+x} ]; then \ - NZBGET_RELEASE=$(curl -sX GET "https://api.github.com/repos/nzbget/nzbget/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + NZBGET_RELEASE=$(curl -sX GET "https://api.github.com/repos/nzbgetcom/nzbget/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi && \ - mkdir -p /app/nzbget && \ - git clone https://github.com/nzbget/nzbget.git nzbget && \ + mkdir -p /nzbget && \ + git clone https://github.com/nzbgetcom/nzbget.git nzbget && \ cd nzbget/ && \ git checkout ${NZBGET_RELEASE} && \ - git cherry-pick -n fa57474d && \ - ./configure \ - bindir='${exec_prefix}' && \ - make && \ - make prefix=/app/nzbget install && \ + mkdir -p build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/app/nzbget && \ + cmake --build . -j 2 && \ + cmake --install . && \ + mv /app/nzbget/bin/nzbget /app/nzbget/ && \ + rm -rf /app/nzbget/bin/ && \ + rm -rf /app/nzbget/etc/ && \ sed -i \ - -e "s#^MainDir=.*#MainDir=/downloads#g" \ - -e "s#^ScriptDir=.*#ScriptDir=$\{MainDir\}/scripts#g" \ - -e "s#^WebDir=.*#WebDir=$\{AppDir\}/webui#g" \ - -e "s#^ConfigTemplate=.*#ConfigTemplate=$\{AppDir\}/webui/nzbget.conf.template#g" \ - -e "s#^UnrarCmd=.*#UnrarCmd=$\{AppDir\}/unrar#g" \ - -e "s#^SevenZipCmd=.*#SevenZipCmd=$\{AppDir\}/7za#g" \ - -e "s#^CertStore=.*#CertStore=$\{AppDir\}/cacert.pem#g" \ - -e "s#^CertCheck=.*#CertCheck=yes#g" \ - -e "s#^DestDir=.*#DestDir=$\{MainDir\}/completed#g" \ - -e "s#^InterDir=.*#InterDir=$\{MainDir\}/intermediate#g" \ - -e "s#^LogFile=.*#LogFile=$\{MainDir\}/nzbget.log#g" \ - -e "s#^AuthorizedIP=.*#AuthorizedIP=127.0.0.1#g" \ + -e "s|^MainDir=.*|MainDir=/downloads|g" \ + -e "s|^ScriptDir=.*|ScriptDir=$\{MainDir\}/scripts|g" \ + -e "s|^WebDir=.*|WebDir=$\{AppDir\}/webui|g" \ + -e "s|^ConfigTemplate=.*|ConfigTemplate=$\{AppDir\}/webui/nzbget.conf.template|g" \ + -e "s|^UnrarCmd=.*|UnrarCmd=unrar|g" \ + -e "s|^SevenZipCmd=.*|SevenZipCmd=7z|g" \ + -e "s|^CertStore=.*|CertStore=$\{AppDir\}/cacert.pem|g" \ + -e "s|^CertCheck=.*|CertCheck=yes|g" \ + -e "s|^DestDir=.*|DestDir=$\{MainDir\}/completed|g" \ + -e "s|^InterDir=.*|InterDir=$\{MainDir\}/intermediate|g" \ + -e "s|^LogFile=.*|LogFile=$\{MainDir\}/nzbget.log|g" \ + -e "s|^AuthorizedIP=.*|AuthorizedIP=127.0.0.1|g" \ /app/nzbget/share/nzbget/nzbget.conf && \ mv /app/nzbget/share/nzbget/webui /app/nzbget/ && \ cp /app/nzbget/share/nzbget/nzbget.conf /app/nzbget/webui/nzbget.conf.template && \ - ln -s /usr/bin/7za /app/nzbget/7za && \ + ln -s /usr/bin/7z /app/nzbget/7za && \ ln -s /usr/bin/unrar /app/nzbget/unrar && \ cp /nzbget/pubkey.pem /app/nzbget/pubkey.pem && \ - curl -o \ - /app/nzbget/cacert.pem -L \ - "https://curl.haxx.se/ca/cacert.pem" + curl -o /app/nzbget/cacert.pem -L "https://curl.se/ca/cacert.pem" # Runtime Stage -FROM ghcr.io/linuxserver/baseimage-alpine:3.16 +FROM ghcr.io/linuxserver/baseimage-alpine:3.19 -ARG UNRAR_VERSION=6.1.7 # set version label ARG BUILD_DATE ARG VERSION @@ -65,48 +68,24 @@ LABEL maintainer="thelamer" RUN \ echo "**** install build packages ****" && \ apk add --no-cache --upgrade --virtual=build-dependencies \ - cargo \ - g++ \ - gcc \ - libc-dev \ - libffi-dev \ - libxml2-dev \ - libxslt-dev \ - make \ - openssl-dev \ - python3-dev && \ + build-base && \ echo "**** install packages ****" && \ apk add --no-cache \ + 7zip \ + boost1.82-json \ libxml2 \ libxslt \ openssl \ - p7zip \ - py3-pip \ python3 && \ - echo "**** install unrar from source ****" && \ - mkdir /tmp/unrar && \ - curl -o \ - /tmp/unrar.tar.gz -L \ - "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \ - tar xf \ - /tmp/unrar.tar.gz -C \ - /tmp/unrar --strip-components=1 && \ - cd /tmp/unrar && \ - make && \ - install -v -m755 unrar /usr/bin && \ echo "**** install python packages ****" && \ - pip3 install --no-cache-dir -U \ + python3 -m venv /lsiopy && \ + pip install -U --no-cache-dir \ pip \ wheel && \ - pip install --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.16/ \ + pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.19/ \ apprise \ - chardet \ - lxml \ - py7zr \ - pynzbget \ - rarfile \ - six && \ - ln -s /usr/bin/python3 /usr/bin/python && \ + pynzb \ + requests && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ @@ -119,6 +98,9 @@ RUN \ COPY --from=buildstage /app/nzbget /app/nzbget COPY root/ / +# add unrar +COPY --from=unrar /usr/bin/unrar-alpine /usr/bin/unrar + # ports and volumes VOLUME /config EXPOSE 6789 diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 5b33ec8..ee9882d 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,5 +1,8 @@ -# Buildstage -FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.16 as buildstage +# syntax=docker/dockerfile:1 + +FROM ghcr.io/linuxserver/unrar:arm64v8-latest as unrar + +FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.19 as buildstage # set NZBGET version ARG NZBGET_RELEASE @@ -7,55 +10,55 @@ ARG NZBGET_RELEASE RUN \ echo "**** install build packages ****" && \ apk add \ - g++ \ - gcc \ + boost-dev \ + build-base \ + cmake \ git \ libxml2-dev \ libxslt-dev \ - make \ ncurses-dev \ openssl-dev && \ echo "**** build nzbget ****" && \ if [ -z ${NZBGET_RELEASE+x} ]; then \ - NZBGET_RELEASE=$(curl -sX GET "https://api.github.com/repos/nzbget/nzbget/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + NZBGET_RELEASE=$(curl -sX GET "https://api.github.com/repos/nzbgetcom/nzbget/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi && \ - mkdir -p /app/nzbget && \ - git clone https://github.com/nzbget/nzbget.git nzbget && \ + mkdir -p /nzbget && \ + git clone https://github.com/nzbgetcom/nzbget.git nzbget && \ cd nzbget/ && \ git checkout ${NZBGET_RELEASE} && \ - git cherry-pick -n fa57474d && \ - ./configure \ - bindir='${exec_prefix}' && \ - make && \ - make prefix=/app/nzbget install && \ + mkdir -p build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/app/nzbget && \ + cmake --build . -j 2 && \ + cmake --install . && \ + mv /app/nzbget/bin/nzbget /app/nzbget/ && \ + rm -rf /app/nzbget/bin/ && \ + rm -rf /app/nzbget/etc/ && \ sed -i \ - -e "s#^MainDir=.*#MainDir=/downloads#g" \ - -e "s#^ScriptDir=.*#ScriptDir=$\{MainDir\}/scripts#g" \ - -e "s#^WebDir=.*#WebDir=$\{AppDir\}/webui#g" \ - -e "s#^ConfigTemplate=.*#ConfigTemplate=$\{AppDir\}/webui/nzbget.conf.template#g" \ - -e "s#^UnrarCmd=.*#UnrarCmd=$\{AppDir\}/unrar#g" \ - -e "s#^SevenZipCmd=.*#SevenZipCmd=$\{AppDir\}/7za#g" \ - -e "s#^CertStore=.*#CertStore=$\{AppDir\}/cacert.pem#g" \ - -e "s#^CertCheck=.*#CertCheck=yes#g" \ - -e "s#^DestDir=.*#DestDir=$\{MainDir\}/completed#g" \ - -e "s#^InterDir=.*#InterDir=$\{MainDir\}/intermediate#g" \ - -e "s#^LogFile=.*#LogFile=$\{MainDir\}/nzbget.log#g" \ - -e "s#^AuthorizedIP=.*#AuthorizedIP=127.0.0.1#g" \ + -e "s|^MainDir=.*|MainDir=/downloads|g" \ + -e "s|^ScriptDir=.*|ScriptDir=$\{MainDir\}/scripts|g" \ + -e "s|^WebDir=.*|WebDir=$\{AppDir\}/webui|g" \ + -e "s|^ConfigTemplate=.*|ConfigTemplate=$\{AppDir\}/webui/nzbget.conf.template|g" \ + -e "s|^UnrarCmd=.*|UnrarCmd=unrar|g" \ + -e "s|^SevenZipCmd=.*|SevenZipCmd=7z|g" \ + -e "s|^CertStore=.*|CertStore=$\{AppDir\}/cacert.pem|g" \ + -e "s|^CertCheck=.*|CertCheck=yes|g" \ + -e "s|^DestDir=.*|DestDir=$\{MainDir\}/completed|g" \ + -e "s|^InterDir=.*|InterDir=$\{MainDir\}/intermediate|g" \ + -e "s|^LogFile=.*|LogFile=$\{MainDir\}/nzbget.log|g" \ + -e "s|^AuthorizedIP=.*|AuthorizedIP=127.0.0.1|g" \ /app/nzbget/share/nzbget/nzbget.conf && \ mv /app/nzbget/share/nzbget/webui /app/nzbget/ && \ cp /app/nzbget/share/nzbget/nzbget.conf /app/nzbget/webui/nzbget.conf.template && \ - ln -s /usr/bin/7za /app/nzbget/7za && \ + ln -s /usr/bin/7z /app/nzbget/7za && \ ln -s /usr/bin/unrar /app/nzbget/unrar && \ cp /nzbget/pubkey.pem /app/nzbget/pubkey.pem && \ - curl -o \ - /app/nzbget/cacert.pem -L \ - "https://curl.haxx.se/ca/cacert.pem" + curl -o /app/nzbget/cacert.pem -L "https://curl.se/ca/cacert.pem" # Runtime Stage -FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.16 +FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.19 -ARG UNRAR_VERSION=6.1.7 # set version label ARG BUILD_DATE ARG VERSION @@ -65,48 +68,24 @@ LABEL maintainer="thelamer" RUN \ echo "**** install build packages ****" && \ apk add --no-cache --upgrade --virtual=build-dependencies \ - cargo \ - g++ \ - gcc \ - libc-dev \ - libffi-dev \ - libxml2-dev \ - libxslt-dev \ - make \ - openssl-dev \ - python3-dev && \ + build-base && \ echo "**** install packages ****" && \ apk add --no-cache \ + 7zip \ + boost1.82-json \ libxml2 \ libxslt \ openssl \ - p7zip \ - py3-pip \ python3 && \ - echo "**** install unrar from source ****" && \ - mkdir /tmp/unrar && \ - curl -o \ - /tmp/unrar.tar.gz -L \ - "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \ - tar xf \ - /tmp/unrar.tar.gz -C \ - /tmp/unrar --strip-components=1 && \ - cd /tmp/unrar && \ - make && \ - install -v -m755 unrar /usr/bin && \ echo "**** install python packages ****" && \ - pip3 install --no-cache-dir -U \ + python3 -m venv /lsiopy && \ + pip install -U --no-cache-dir \ pip \ wheel && \ - pip install --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.16/ \ + pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.19/ \ apprise \ - chardet \ - lxml \ - py7zr \ - pynzbget \ - rarfile \ - six && \ - ln -s /usr/bin/python3 /usr/bin/python && \ + pynzb \ + requests && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ @@ -119,6 +98,9 @@ RUN \ COPY --from=buildstage /app/nzbget /app/nzbget COPY root/ / +# add unrar +COPY --from=unrar /usr/bin/unrar-alpine /usr/bin/unrar + # ports and volumes VOLUME /config EXPOSE 6789 diff --git a/Dockerfile.armhf b/Dockerfile.armhf deleted file mode 100644 index 3ffa776..0000000 --- a/Dockerfile.armhf +++ /dev/null @@ -1,124 +0,0 @@ -# Buildstage -FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.16 as buildstage - -# set NZBGET version -ARG NZBGET_RELEASE - -RUN \ - echo "**** install build packages ****" && \ - apk add \ - g++ \ - gcc \ - git \ - libxml2-dev \ - libxslt-dev \ - make \ - ncurses-dev \ - openssl-dev && \ - echo "**** build nzbget ****" && \ - if [ -z ${NZBGET_RELEASE+x} ]; then \ - NZBGET_RELEASE=$(curl -sX GET "https://api.github.com/repos/nzbget/nzbget/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - mkdir -p /app/nzbget && \ - git clone https://github.com/nzbget/nzbget.git nzbget && \ - cd nzbget/ && \ - git checkout ${NZBGET_RELEASE} && \ - git cherry-pick -n fa57474d && \ - ./configure \ - bindir='${exec_prefix}' && \ - make && \ - make prefix=/app/nzbget install && \ - sed -i \ - -e "s#^MainDir=.*#MainDir=/downloads#g" \ - -e "s#^ScriptDir=.*#ScriptDir=$\{MainDir\}/scripts#g" \ - -e "s#^WebDir=.*#WebDir=$\{AppDir\}/webui#g" \ - -e "s#^ConfigTemplate=.*#ConfigTemplate=$\{AppDir\}/webui/nzbget.conf.template#g" \ - -e "s#^UnrarCmd=.*#UnrarCmd=$\{AppDir\}/unrar#g" \ - -e "s#^SevenZipCmd=.*#SevenZipCmd=$\{AppDir\}/7za#g" \ - -e "s#^CertStore=.*#CertStore=$\{AppDir\}/cacert.pem#g" \ - -e "s#^CertCheck=.*#CertCheck=yes#g" \ - -e "s#^DestDir=.*#DestDir=$\{MainDir\}/completed#g" \ - -e "s#^InterDir=.*#InterDir=$\{MainDir\}/intermediate#g" \ - -e "s#^LogFile=.*#LogFile=$\{MainDir\}/nzbget.log#g" \ - -e "s#^AuthorizedIP=.*#AuthorizedIP=127.0.0.1#g" \ - /app/nzbget/share/nzbget/nzbget.conf && \ - mv /app/nzbget/share/nzbget/webui /app/nzbget/ && \ - cp /app/nzbget/share/nzbget/nzbget.conf /app/nzbget/webui/nzbget.conf.template && \ - ln -s /usr/bin/7za /app/nzbget/7za && \ - ln -s /usr/bin/unrar /app/nzbget/unrar && \ - cp /nzbget/pubkey.pem /app/nzbget/pubkey.pem && \ - curl -o \ - /app/nzbget/cacert.pem -L \ - "https://curl.haxx.se/ca/cacert.pem" - -# Runtime Stage -FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.16 - -ARG UNRAR_VERSION=6.1.7 -# set version label -ARG BUILD_DATE -ARG VERSION -LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="thelamer" - -RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --upgrade --virtual=build-dependencies \ - cargo \ - g++ \ - gcc \ - libc-dev \ - libffi-dev \ - libxml2-dev \ - libxslt-dev \ - make \ - openssl-dev \ - python3-dev && \ - echo "**** install packages ****" && \ - apk add --no-cache \ - libxml2 \ - libxslt \ - openssl \ - p7zip \ - py3-pip \ - python3 && \ - echo "**** install unrar from source ****" && \ - mkdir /tmp/unrar && \ - curl -o \ - /tmp/unrar.tar.gz -L \ - "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \ - tar xf \ - /tmp/unrar.tar.gz -C \ - /tmp/unrar --strip-components=1 && \ - cd /tmp/unrar && \ - make && \ - install -v -m755 unrar /usr/bin && \ - echo "**** install python packages ****" && \ - pip3 install --no-cache-dir -U \ - pip \ - wheel && \ - pip install --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.16/ \ - apprise \ - chardet \ - lxml \ - py7zr \ - pynzbget \ - rarfile \ - six && \ - ln -s /usr/bin/python3 /usr/bin/python && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /root/.cache \ - /root/.cargo \ - /tmp/* - -# add local files and files from buildstage -COPY --from=buildstage /app/nzbget /app/nzbget -COPY root/ / - -# ports and volumes -VOLUME /config -EXPOSE 6789 diff --git a/Jenkinsfile b/Jenkinsfile index d9acdd9..35ac279 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,9 +16,8 @@ pipeline { GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0') GITLAB_NAMESPACE=credentials('gitlab-namespace-id') - SCARF_TOKEN=credentials('scarf_api_key') - EXT_GIT_BRANCH = 'master' - EXT_USER = 'nzbget' + DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat') + EXT_USER = 'nzbgetcom' EXT_REPO = 'nzbget' BUILD_VERSION_ARG = 'NZBGET_RELEASE' LS_USER = 'linuxserver' @@ -33,8 +32,8 @@ pipeline { CI_WEB='true' CI_PORT='6789' CI_SSL='false' - CI_DELAY='120' - CI_DOCKERENV='TZ=US/Pacific' + CI_DELAY='60' + CI_DOCKERENV='' CI_AUTH='nzbget:tegbzn6789' CI_WEBPATH='' } @@ -42,10 +41,16 @@ pipeline { // Setup all the basic environment variables needed for the build stage("Set ENV Variables base"){ steps{ + sh '''#! /bin/bash + containers=$(docker ps -aq) + if [[ -n "${containers}" ]]; then + docker stop ${containers} + fi + docker system prune -af --volumes || : ''' script{ env.EXIT_STATUS = '' env.LS_RELEASE = sh( - script: '''docker run --rm ghcr.io/linuxserver/alexeiled-skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', + script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:latest 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', returnStdout: true).trim() env.LS_RELEASE_NOTES = sh( script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''', @@ -56,11 +61,16 @@ pipeline { env.COMMIT_SHA = sh( script: '''git rev-parse HEAD''', returnStdout: true).trim() + env.GH_DEFAULT_BRANCH = sh( + script: '''git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||' ''', + returnStdout: true).trim() env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/' env.PULL_REQUEST = env.CHANGE_ID - env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./root/donate.txt ./root/etc/cont-init.d/99-deprecation' + env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/call_issue_pr_tracker.yml ./.github/workflows/call_issues_cron.yml ./.github/workflows/permissions.yml ./.github/workflows/external_trigger.yml ./.github/workflows/package_trigger.yml ./root/donate.txt' } + sh '''#! /bin/bash + echo "The default github branch detected as ${GH_DEFAULT_BRANCH}" ''' script{ env.LS_RELEASE_NUMBER = sh( script: '''echo ${LS_RELEASE} |sed 's/^.*-ls//g' ''', @@ -125,7 +135,7 @@ pipeline { steps{ script{ env.EXT_RELEASE_CLEAN = sh( - script: '''echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g' ''', + script: '''echo ${EXT_RELEASE} | sed 's/[~,%@+;:/ ]//g' ''', returnStdout: true).trim() def semver = env.EXT_RELEASE_CLEAN =~ /(\d+)\.(\d+)\.(\d+)/ @@ -143,7 +153,7 @@ pipeline { } if (env.SEMVER != null) { - if (BRANCH_NAME != "master" && BRANCH_NAME != "main") { + if (BRANCH_NAME != "${env.GH_DEFAULT_BRANCH}") { env.SEMVER = "${env.SEMVER}-${BRANCH_NAME}" } println("SEMVER: ${env.SEMVER}") @@ -167,7 +177,7 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } else { env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } @@ -190,7 +200,7 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/lsiodev-' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/lsiodev-' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA } else { env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA } @@ -213,12 +223,12 @@ pipeline { env.GITLABIMAGE = 'registry.gitlab.com/linuxserver.io/' + env.LS_REPO + '/lspipepr-' + env.CONTAINER_NAME env.QUAYIMAGE = 'quay.io/linuxserver.io/lspipepr-' + env.CONTAINER_NAME if (env.MULTIARCH == 'true') { - env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + '|arm32v7-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + env.CI_TAGS = 'amd64-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST + '|arm64v8-' + env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST } else { - env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + env.CI_TAGS = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST } - env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST - env.META_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-pr-' + env.PULL_REQUEST + env.VERSION_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST + env.META_TAG = env.EXT_RELEASE_CLEAN + '-pkg-' + env.PACKAGE_TAG + '-dev-' + env.COMMIT_SHA + '-pr-' + env.PULL_REQUEST env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/pull/' + env.PULL_REQUEST env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.PR_DOCKERHUB_IMAGE + '/tags/' @@ -238,19 +248,18 @@ pipeline { script{ env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml' } - sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash''' + sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash''' sh '''#! /bin/bash - set -e - docker pull ghcr.io/linuxserver/lsiodev-spaces-file-upload:latest docker run --rm \ - -e DESTINATION=\"${IMAGE}/${META_TAG}/shellcheck-result.xml\" \ - -e FILE_NAME="shellcheck-result.xml" \ - -e MIMETYPE="text/xml" \ - -v ${WORKSPACE}:/mnt \ - -e SECRET_KEY=\"${S3_SECRET}\" \ - -e ACCESS_KEY=\"${S3_KEY}\" \ - -t ghcr.io/linuxserver/lsiodev-spaces-file-upload:latest \ - python /upload.py''' + -v ${WORKSPACE}:/mnt \ + -e AWS_ACCESS_KEY_ID=\"${S3_KEY}\" \ + -e AWS_SECRET_ACCESS_KEY=\"${S3_SECRET}\" \ + ghcr.io/linuxserver/baseimage-alpine:3.19 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\ + apk add --no-cache python3 && \ + python3 -m venv /lsiopy && \ + pip install --no-cache-dir -U pip && \ + pip install --no-cache-dir s3cmd && \ + s3cmd put --no-preserve --acl-public -m text/xml /mnt/shellcheck-result.xml s3://ci-tests.linuxserver.io/${IMAGE}/${META_TAG}/shellcheck-result.xml" || :''' } } } @@ -268,8 +277,15 @@ pipeline { set -e TEMPDIR=$(mktemp -d) docker pull ghcr.io/linuxserver/jenkins-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=master -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest - # Stage 1 - Jenkinsfile update + # Cloned repo paths for templating: + # ${TEMPDIR}/docker-${CONTAINER_NAME}: Cloned branch master of ${LS_USER}/${LS_REPO} for running the jenkins builder on + # ${TEMPDIR}/repo/${LS_REPO}: Cloned branch master of ${LS_USER}/${LS_REPO} for commiting various templated file changes and pushing back to Github + # ${TEMPDIR}/docs/docker-documentation: Cloned docs repo for pushing docs updates to Github + # ${TEMPDIR}/unraid/docker-templates: Cloned docker-templates repo to check for logos + # ${TEMPDIR}/unraid/templates: Cloned templates repo for commiting unraid template changes and pushing back to Github + git clone --branch master --depth 1 https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/docker-${CONTAINER_NAME} + docker run --rm -v ${TEMPDIR}/docker-${CONTAINER_NAME}:/tmp -e LOCAL=true -e PUID=$(id -u) -e PGID=$(id -g) ghcr.io/linuxserver/jenkins-builder:latest + echo "Starting Stage 1 - Jenkinsfile update" if [[ "$(md5sum Jenkinsfile | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile | awk '{ print $1 }')" ]]; then mkdir -p ${TEMPDIR}/repo git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} @@ -278,16 +294,17 @@ pipeline { cp ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile ${TEMPDIR}/repo/${LS_REPO}/ git add Jenkinsfile git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} - echo "Updating Jenkinsfile" + echo "Updating Jenkinsfile and exiting build, new one will trigger based on commit" rm -Rf ${TEMPDIR} exit 0 else echo "Jenkinsfile is up to date." fi - # Stage 2 - Delete old templates - OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md\n.github/ISSUE_TEMPLATE/issue.bug.md\n.github/ISSUE_TEMPLATE/issue.feature.md" + echo "Starting Stage 2 - Delete old templates" + OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md .github/ISSUE_TEMPLATE/issue.bug.md .github/ISSUE_TEMPLATE/issue.feature.md .github/workflows/call_invalid_helper.yml .github/workflows/stale.yml Dockerfile.armhf" for i in ${OLD_TEMPLATES}; do if [[ -f "${i}" ]]; then TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}" @@ -302,15 +319,16 @@ pipeline { git rm "${i}" done git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} - echo "Deleting old templates" + echo "Deleting old/deprecated templates and exiting build, new one will trigger based on commit" rm -Rf ${TEMPDIR} exit 0 else echo "No templates to delete" fi - # Stage 3 - Update templates + echo "Starting Stage 3 - Update templates" CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) cd ${TEMPDIR}/docker-${CONTAINER_NAME} NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) @@ -322,43 +340,59 @@ pipeline { cd ${TEMPDIR}/docker-${CONTAINER_NAME} mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE - mkdir -p ${TEMPDIR}/repo/${LS_REPO}/root/etc/cont-init.d cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || : + cp --parents readme-vars.yml ${TEMPDIR}/repo/${LS_REPO}/ || : cd ${TEMPDIR}/repo/${LS_REPO}/ if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then echo ".jenkins-external" >> .gitignore git add .gitignore fi - git add ${TEMPLATED_FILES} - git rm ${TEMPDIR}/repo/${LS_REPO}/.github/workflows/{external_trigger,external_trigger_scheduler,package_trigger,package_trigger_scheduler}.yml || : + git add readme-vars.yml ${TEMPLATED_FILES} git commit -m 'Bot Updating Templated Files' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "Updating templates and exiting build, new one will trigger based on commit" + rm -Rf ${TEMPDIR} + exit 0 else echo "false" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER} + echo "No templates to update" fi - mkdir -p ${TEMPDIR}/gitbook - git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/gitbook/docker-documentation - if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then - cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/ - cd ${TEMPDIR}/gitbook/docker-documentation/ - git add images/docker-${CONTAINER_NAME}.md + echo "Starting Stage 4 - External repo updates: Docs, Unraid Template and Readme Sync to Docker Hub" + mkdir -p ${TEMPDIR}/docs + git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/docs/docker-documentation + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]] && [[ (! -f ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/docs/docker-documentation/docs/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then + cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/docker-${CONTAINER_NAME}.md ${TEMPDIR}/docs/docker-documentation/docs/images/ + cd ${TEMPDIR}/docs/docker-documentation + GH_DOCS_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||') + git add docs/images/docker-${CONTAINER_NAME}.md + echo "Updating docs repo" git commit -m 'Bot Updating Documentation' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} || \ + (MAXWAIT="10" && echo "Push to docs failed, trying again in ${MAXWAIT} seconds" && \ + sleep $((RANDOM % MAXWAIT)) && \ + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH} --rebase && \ + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git ${GH_DOCS_DEFAULT_BRANCH}) + else + echo "Docs update not needed, skipping" fi mkdir -p ${TEMPDIR}/unraid git clone https://github.com/linuxserver/docker-templates.git ${TEMPDIR}/unraid/docker-templates git clone https://github.com/linuxserver/templates.git ${TEMPDIR}/unraid/templates if [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-logo.png ]]; then sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-logo.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml + elif [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-icon.png ]]; then + sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-icon.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml fi - if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then + echo "Updating Unraid template" cd ${TEMPDIR}/unraid/templates/ - if ! grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then - echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list - git add unraid/ignore.list - fi - if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then + GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||') + if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then + echo "Image is on the ignore list, and already in the deprecation folder." + elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then echo "Image is on the ignore list, marking Unraid template as deprecated" cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/ git add -u unraid/${CONTAINER_NAME}.xml @@ -369,7 +403,42 @@ pipeline { git add unraid/${CONTAINER_NAME}.xml git commit -m 'Bot Updating Unraid Template' fi - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} --rebase + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} || \ + (MAXWAIT="10" && echo "Push to unraid templates failed, trying again in ${MAXWAIT} seconds" && \ + sleep $((RANDOM % MAXWAIT)) && \ + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH} --rebase && \ + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git ${GH_TEMPLATES_DEFAULT_BRANCH}) + else + echo "No updates to Unraid template needed, skipping" + fi + if [[ "${BRANCH_NAME}" == "${GH_DEFAULT_BRANCH}" ]]; then + if [[ $(cat ${TEMPDIR}/docker-${CONTAINER_NAME}/README.md | wc -m) -gt 25000 ]]; then + echo "Readme is longer than 25,000 characters. Syncing the lite version to Docker Hub" + DH_README_SYNC_PATH="${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/README.lite" + else + echo "Syncing readme to Docker Hub" + DH_README_SYNC_PATH="${TEMPDIR}/docker-${CONTAINER_NAME}/README.md" + fi + if curl -s https://hub.docker.com/v2/namespaces/${DOCKERHUB_IMAGE%%/*}/repositories/${DOCKERHUB_IMAGE##*/}/tags | jq -r '.message' | grep -q 404; then + echo "Docker Hub endpoint doesn't exist. Creating endpoint first." + DH_TOKEN=$(curl -d '{"username":"linuxserverci", "password":"'${DOCKERHUB_TOKEN}'"}' -H "Content-Type: application/json" -X POST https://hub.docker.com/v2/users/login | jq -r '.token') + curl -s \ + -H "Authorization: JWT ${DH_TOKEN}" \ + -H "Content-Type: application/json" \ + -X POST \ + -d '{"name":"'${DOCKERHUB_IMAGE##*/}'", "namespace":"'${DOCKERHUB_IMAGE%%/*}'"}' \ + https://hub.docker.com/v2/repositories/ || : + fi + DH_TOKEN=$(curl -d '{"username":"linuxserverci", "password":"'${DOCKERHUB_TOKEN}'"}' -H "Content-Type: application/json" -X POST https://hub.docker.com/v2/users/login | jq -r '.token') + curl -s \ + -H "Authorization: JWT ${DH_TOKEN}" \ + -H "Content-Type: application/json" \ + -X PATCH \ + -d "{\\"full_description\\":$(jq -Rsa . ${DH_README_SYNC_PATH})}" \ + https://hub.docker.com/v2/repositories/${DOCKERHUB_IMAGE} || : + else + echo "Not the default Github branch. Skipping readme sync to Docker Hub." fi rm -Rf ${TEMPDIR}''' script{ @@ -395,54 +464,46 @@ pipeline { } } } - /* ####################### - GitLab Mirroring - ####################### */ - // Ping into Gitlab to mirror this repo and have a registry endpoint - stage("GitLab Mirror"){ + // If this is a master build check the S6 service file perms + stage("Check S6 Service file Permissions"){ when { + branch "master" + environment name: 'CHANGE_ID', value: '' environment name: 'EXIT_STATUS', value: '' } - steps{ - sh '''curl -H "Content-Type: application/json" -H "Private-Token: ${GITLAB_TOKEN}" -X POST https://gitlab.com/api/v4/projects \ - -d '{"namespace_id":'${GITLAB_NAMESPACE}',\ - "name":"'${LS_REPO}'", - "mirror":true,\ - "import_url":"https://github.com/linuxserver/'${LS_REPO}'.git",\ - "issues_access_level":"disabled",\ - "merge_requests_access_level":"disabled",\ - "repository_access_level":"enabled",\ - "visibility":"public"}' ''' - } + steps { + script{ + sh '''#! /bin/bash + WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print) + if [[ -n "${WRONG_PERM}" ]]; then + echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}" + exit 1 + else + echo "S6 service file perms look good." + fi ''' + } + } } /* ####################### - Scarf.sh package registry + GitLab Mirroring ####################### */ - // Add package to Scarf.sh and set permissions - stage("Scarf.sh package registry"){ + // Ping into Gitlab to mirror this repo and have a registry endpoint + stage("GitLab Mirror"){ when { - branch "master" environment name: 'EXIT_STATUS', value: '' } steps{ - sh '''#! /bin/bash - set -e - PACKAGE_UUID=$(curl -X GET -H "Authorization: Bearer ${SCARF_TOKEN}" https://scarf.sh/api/v1/organizations/linuxserver-ci/packages | jq -r '.[] | select(.name=="linuxserver/nzbget") | .uuid') - if [ -z "${PACKAGE_UUID}" ]; then - echo "Adding package to Scarf.sh" - curl -sX POST https://scarf.sh/api/v1/organizations/linuxserver-ci/packages \ - -H "Authorization: Bearer ${SCARF_TOKEN}" \ - -H "Content-Type: application/json" \ - -d '{"name":"linuxserver/nzbget",\ - "shortDescription":"example description",\ - "libraryType":"docker",\ - "website":"https://github.com/linuxserver/docker-nzbget",\ - "backendUrl":"https://ghcr.io/linuxserver/nzbget",\ - "publicUrl":"https://lscr.io/linuxserver/nzbget"}' || : - else - echo "Package already exists on Scarf.sh" - fi - ''' + sh '''curl -H "Content-Type: application/json" -H "Private-Token: ${GITLAB_TOKEN}" -X POST https://gitlab.com/api/v4/projects \ + -d '{"namespace_id":'${GITLAB_NAMESPACE}',\ + "name":"'${LS_REPO}'", + "mirror":true,\ + "import_url":"https://github.com/linuxserver/'${LS_REPO}'.git",\ + "issues_access_level":"disabled",\ + "merge_requests_access_level":"disabled",\ + "repository_access_level":"enabled",\ + "visibility":"public"}' ''' + sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \ + -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" ''' } } /* ############### @@ -458,7 +519,8 @@ pipeline { } steps { echo "Running on node: ${NODE_NAME}" - sh "docker build \ + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile" + sh "docker buildx build \ --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ --label \"org.opencontainers.image.authors=linuxserver.io\" \ --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-nzbget/packages\" \ @@ -470,8 +532,8 @@ pipeline { --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ --label \"org.opencontainers.image.title=Nzbget\" \ - --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.net/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ - --no-cache --pull -t ${IMAGE}:${META_TAG} \ + --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.com/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ + --no-cache --pull -t ${IMAGE}:${META_TAG} --platform=linux/amd64 \ --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." } } @@ -488,7 +550,8 @@ pipeline { stage('Build X86') { steps { echo "Running on node: ${NODE_NAME}" - sh "docker build \ + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile" + sh "docker buildx build \ --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ --label \"org.opencontainers.image.authors=linuxserver.io\" \ --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-nzbget/packages\" \ @@ -500,45 +563,11 @@ pipeline { --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ --label \"org.opencontainers.image.title=Nzbget\" \ - --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.net/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ - --no-cache --pull -t ${IMAGE}:amd64-${META_TAG} \ + --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.com/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ + --no-cache --pull -t ${IMAGE}:amd64-${META_TAG} --platform=linux/amd64 \ --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." } } - stage('Build ARMHF') { - agent { - label 'ARMHF' - } - steps { - echo "Running on node: ${NODE_NAME}" - echo 'Logging into Github' - sh '''#! /bin/bash - echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin - ''' - sh "docker build \ - --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ - --label \"org.opencontainers.image.authors=linuxserver.io\" \ - --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-nzbget/packages\" \ - --label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-nzbget\" \ - --label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-nzbget\" \ - --label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \ - --label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.vendor=linuxserver.io\" \ - --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ - --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ - --label \"org.opencontainers.image.title=Nzbget\" \ - --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.net/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ - --no-cache --pull -f Dockerfile.armhf -t ${IMAGE}:arm32v7-${META_TAG} \ - --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." - sh "docker tag ${IMAGE}:arm32v7-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}" - retry(5) { - sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}" - } - sh '''docker rmi \ - ${IMAGE}:arm32v7-${META_TAG} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} || :''' - } - } stage('Build ARM64') { agent { label 'ARM64' @@ -549,7 +578,8 @@ pipeline { sh '''#! /bin/bash echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin ''' - sh "docker build \ + sh "sed -r -i 's|(^FROM .*)|\\1\\n\\nENV LSIO_FIRST_PARTY=true|g' Dockerfile.aarch64" + sh "docker buildx build \ --label \"org.opencontainers.image.created=${GITHUB_DATE}\" \ --label \"org.opencontainers.image.authors=linuxserver.io\" \ --label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-nzbget/packages\" \ @@ -561,16 +591,19 @@ pipeline { --label \"org.opencontainers.image.licenses=GPL-3.0-only\" \ --label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \ --label \"org.opencontainers.image.title=Nzbget\" \ - --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.net/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ - --no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} \ + --label \"org.opencontainers.image.description=[Nzbget](http://nzbget.com/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources.\" \ + --no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} --platform=linux/arm64 \ --build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ." sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}" retry(5) { sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}" } - sh '''docker rmi \ - ${IMAGE}:arm64v8-${META_TAG} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || :''' + sh '''#! /bin/bash + containers=$(docker ps -aq) + if [[ -n "${containers}" ]]; then + docker stop ${containers} + fi + docker system prune -af --volumes || : ''' } } } @@ -586,31 +619,17 @@ pipeline { sh '''#! /bin/bash set -e TEMPDIR=$(mktemp -d) - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then + if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" != "true" ]; then LOCAL_CONTAINER=${IMAGE}:amd64-${META_TAG} else LOCAL_CONTAINER=${IMAGE}:${META_TAG} fi - if [ "${DIST_IMAGE}" == "alpine" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apk info -v > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "ubuntu" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apt list -qq --installed | sed "s#/.*now ##g" | cut -d" " -f1 > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "fedora" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - rpm -qa > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "arch" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - pacman -Q > /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - fi + touch ${TEMPDIR}/package_versions.txt + docker run --rm \ + -v /var/run/docker.sock:/var/run/docker.sock:ro \ + -v ${TEMPDIR}:/tmp \ + ghcr.io/anchore/syft:latest \ + ${LOCAL_CONTAINER} -o table=/tmp/package_versions.txt NEW_PACKAGE_TAG=$(md5sum ${TEMPDIR}/package_versions.txt | cut -c1-8 ) echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github" if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then @@ -621,7 +640,8 @@ pipeline { wait git add package_versions.txt git commit -m 'Bot Updating Package Versions' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all + git pull https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master + git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git master echo "true" > /tmp/packages-${COMMIT_SHA}-${BUILD_NUMBER} echo "Package tag updated, stopping build process" else @@ -645,13 +665,6 @@ pipeline { environment name: 'EXIT_STATUS', value: '' } steps { - sh '''#! /bin/bash - echo "Packages were updated. Cleaning up the image and exiting." - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then - docker rmi ${IMAGE}:amd64-${META_TAG} - else - docker rmi ${IMAGE}:${META_TAG} - fi''' script{ env.EXIT_STATUS = 'ABORTED' } @@ -669,13 +682,6 @@ pipeline { } } steps { - sh '''#! /bin/bash - echo "There are no package updates. Cleaning up the image and exiting." - if [ "${MULTIARCH}" == "true" ] && [ "${PACKAGE_CHECK}" == "false" ]; then - docker rmi ${IMAGE}:amd64-${META_TAG} - else - docker rmi ${IMAGE}:${META_TAG} - fi''' script{ env.EXIT_STATUS = 'ABORTED' } @@ -697,14 +703,13 @@ pipeline { ]) { script{ env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html' + env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json' } sh '''#! /bin/bash set -e docker pull ghcr.io/linuxserver/ci:latest if [ "${MULTIARCH}" == "true" ]; then - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} - docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm32v7-${META_TAG} docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} fi docker run --rm \ @@ -723,8 +728,6 @@ pipeline { -e WEB_SCREENSHOT=\"${CI_WEB}\" \ -e WEB_AUTH=\"${CI_AUTH}\" \ -e WEB_PATH=\"${CI_WEBPATH}\" \ - -e DO_REGION="ams3" \ - -e DO_BUCKET="lsio-ci" \ -t ghcr.io/linuxserver/ci:latest \ python3 test_build.py''' } @@ -741,12 +744,6 @@ pipeline { } steps { withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ], [ $class: 'UsernamePasswordMultiBinding', credentialsId: 'Quay.io-Robot', @@ -757,7 +754,7 @@ pipeline { retry(5) { sh '''#! /bin/bash set -e - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin + echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin @@ -777,17 +774,6 @@ pipeline { done ''' } - sh '''#! /bin/bash - for DELETEIMAGE in "${GITHUBIMAGE}" "${GITLABIMAGE}" "${QUAYIMAGE}" "${IMAGE}"; do - docker rmi \ - ${DELETEIMAGE}:${META_TAG} \ - ${DELETEIMAGE}:${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:latest || : - if [ -n "${SEMVER}" ]; then - docker rmi ${DELETEIMAGE}:${SEMVER} || : - fi - done - ''' } } } @@ -799,12 +785,6 @@ pipeline { } steps { withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ], [ $class: 'UsernamePasswordMultiBinding', credentialsId: 'Quay.io-Robot', @@ -815,63 +795,59 @@ pipeline { retry(5) { sh '''#! /bin/bash set -e - echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin + echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin if [ "${CI}" == "false" ]; then - docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} - docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm32v7-${META_TAG} docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} fi for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do docker tag ${IMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} - docker tag ${IMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} - docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-latest - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-latest - docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} + docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} + docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} if [ -n "${SEMVER}" ]; then docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${SEMVER} - docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${SEMVER} docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${SEMVER} fi docker push ${MANIFESTIMAGE}:amd64-${META_TAG} - docker push ${MANIFESTIMAGE}:arm32v7-${META_TAG} - docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG} + docker push ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} docker push ${MANIFESTIMAGE}:amd64-latest - docker push ${MANIFESTIMAGE}:arm32v7-latest + docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG} docker push ${MANIFESTIMAGE}:arm64v8-latest - docker push ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} - docker push ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} docker push ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} if [ -n "${SEMVER}" ]; then docker push ${MANIFESTIMAGE}:amd64-${SEMVER} - docker push ${MANIFESTIMAGE}:arm32v7-${SEMVER} docker push ${MANIFESTIMAGE}:arm64v8-${SEMVER} fi docker manifest push --purge ${MANIFESTIMAGE}:latest || : - docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:arm64v8-latest - docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm32v7-latest --os linux --arch arm + docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm64v8-latest docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8 docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} || : - docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} - docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} --os linux --arch arm + docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8 docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} || : - docker manifest create ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} - docker manifest annotate ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm32v7-${EXT_RELEASE_TAG} --os linux --arch arm + docker manifest create ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} docker manifest annotate ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} --os linux --arch arm64 --variant v8 if [ -n "${SEMVER}" ]; then docker manifest push --purge ${MANIFESTIMAGE}:${SEMVER} || : - docker manifest create ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm32v7-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} - docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm32v7-${SEMVER} --os linux --arch arm + docker manifest create ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} --os linux --arch arm64 --variant v8 fi + token=$(curl -sX GET "https://ghcr.io/token?scope=repository%3Alinuxserver%2F${CONTAINER_NAME}%3Apull" | jq -r '.token') + digest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/linuxserver/${CONTAINER_NAME}/manifests/arm32v7-latest") + if [[ $(echo "$digest" | jq -r '.layers') != "null" ]]; then + docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest || : + docker manifest create ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:amd64-latest + docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest + fi docker manifest push --purge ${MANIFESTIMAGE}:latest docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} @@ -881,29 +857,6 @@ pipeline { done ''' } - sh '''#! /bin/bash - for DELETEIMAGE in "${GITHUBIMAGE}" "${GITLABIMAGE}" "${QUAYIMAGE}" "${IMAGE}"; do - docker rmi \ - ${DELETEIMAGE}:amd64-${META_TAG} \ - ${DELETEIMAGE}:amd64-latest \ - ${DELETEIMAGE}:amd64-${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:arm32v7-${META_TAG} \ - ${DELETEIMAGE}:arm32v7-latest \ - ${DELETEIMAGE}:arm32v7-${EXT_RELEASE_TAG} \ - ${DELETEIMAGE}:arm64v8-${META_TAG} \ - ${DELETEIMAGE}:arm64v8-latest \ - ${DELETEIMAGE}:arm64v8-${EXT_RELEASE_TAG} || : - if [ -n "${SEMVER}" ]; then - docker rmi \ - ${DELETEIMAGE}:amd64-${SEMVER} \ - ${DELETEIMAGE}:arm32v7-${SEMVER} \ - ${DELETEIMAGE}:arm64v8-${SEMVER} || : - fi - done - docker rmi \ - ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \ - ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || : - ''' } } } @@ -937,49 +890,117 @@ pipeline { curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done''' } } - // Use helper container to sync the current README on master to the dockerhub endpoint - stage('Sync-README') { + // Add protection to the release branch + stage('Github-Release-Branch-Protection') { when { + branch "master" environment name: 'CHANGE_ID', value: '' environment name: 'EXIT_STATUS', value: '' } steps { - withCredentials([ - [ - $class: 'UsernamePasswordMultiBinding', - credentialsId: '3f9ba4d5-100d-45b0-a3c4-633fd6061207', - usernameVariable: 'DOCKERUSER', - passwordVariable: 'DOCKERPASS' - ] - ]) { - sh '''#! /bin/bash - set -e - TEMPDIR=$(mktemp -d) - docker pull ghcr.io/linuxserver/jenkins-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH="${BRANCH_NAME}" -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest - docker pull ghcr.io/linuxserver/readme-sync - docker run --rm=true \ - -e DOCKERHUB_USERNAME=$DOCKERUSER \ - -e DOCKERHUB_PASSWORD=$DOCKERPASS \ - -e GIT_REPOSITORY=${LS_USER}/${LS_REPO} \ - -e DOCKER_REPOSITORY=${IMAGE} \ - -e GIT_BRANCH=master \ - -v ${TEMPDIR}/docker-${CONTAINER_NAME}:/mnt \ - ghcr.io/linuxserver/readme-sync bash -c 'node sync' - rm -Rf ${TEMPDIR} ''' - } + echo "Setting up protection for release branch master" + sh '''#! /bin/bash + curl -H "Authorization: token ${GITHUB_TOKEN}" -X PUT https://api.github.com/repos/${LS_USER}/${LS_REPO}/branches/master/protection \ + -d $(jq -c . << EOF + { + "required_status_checks": null, + "enforce_admins": false, + "required_pull_request_reviews": { + "dismiss_stale_reviews": false, + "require_code_owner_reviews": false, + "require_last_push_approval": false, + "required_approving_review_count": 1 + }, + "restrictions": null, + "required_linear_history": false, + "allow_force_pushes": false, + "allow_deletions": false, + "block_creations": false, + "required_conversation_resolution": true, + "lock_branch": false, + "allow_fork_syncing": false, + "required_signatures": false + } +EOF + ) ''' } } // If this is a Pull request send the CI link as a comment on it stage('Pull Request Comment') { when { not {environment name: 'CHANGE_ID', value: ''} - environment name: 'CI', value: 'true' environment name: 'EXIT_STATUS', value: '' } steps { - sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \ - -d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' ''' + sh '''#! /bin/bash + # Function to retrieve JSON data from URL + get_json() { + local url="$1" + local response=$(curl -s "$url") + if [ $? -ne 0 ]; then + echo "Failed to retrieve JSON data from $url" + return 1 + fi + local json=$(echo "$response" | jq .) + if [ $? -ne 0 ]; then + echo "Failed to parse JSON data from $url" + return 1 + fi + echo "$json" + } + + build_table() { + local data="$1" + + # Get the keys in the JSON data + local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]') + + # Check if keys are empty + if [ -z "$keys" ]; then + echo "JSON report data does not contain any keys or the report does not exist." + return 1 + fi + + # Build table header + local header="| Tag | Passed |\\n| --- | --- |\\n" + + # Loop through the JSON data to build the table rows + local rows="" + for build in $keys; do + local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success") + if [ "$status" = "true" ]; then + status="✅" + else + status="❌" + fi + local row="| "$build" | "$status" |\\n" + rows="${rows}${row}" + done + + local table="${header}${rows}" + local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g') + echo "$escaped_table" + } + + if [[ "${CI}" = "true" ]]; then + # Retrieve JSON data from URL + data=$(get_json "$CI_JSON_URL") + # Create table from JSON data + table=$(build_table "$data") + echo -e "$table" + + curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \ + -d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}" + else + curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \ + -d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}" + fi + ''' + } } } @@ -993,18 +1014,26 @@ pipeline { sh 'echo "build aborted"' } else if (currentBuild.currentResult == "SUCCESS"){ - sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png","embeds": [{"color": 1681177,\ + sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/jenkins-avatar.png","embeds": [{"color": 1681177,\ "description": "**Build:** '${BUILD_NUMBER}'\\n**CI Results:** '${CI_URL}'\\n**ShellCheck Results:** '${SHELLCHECK_URL}'\\n**Status:** Success\\n**Job:** '${RUN_DISPLAY_URL}'\\n**Change:** '${CODE_URL}'\\n**External Release:**: '${RELEASE_LINK}'\\n**DockerHub:** '${DOCKERHUB_LINK}'\\n"}],\ "username": "Jenkins"}' ${BUILDS_DISCORD} ''' } else { - sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png","embeds": [{"color": 16711680,\ + sh ''' curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/jenkins-avatar.png","embeds": [{"color": 16711680,\ "description": "**Build:** '${BUILD_NUMBER}'\\n**CI Results:** '${CI_URL}'\\n**ShellCheck Results:** '${SHELLCHECK_URL}'\\n**Status:** failure\\n**Job:** '${RUN_DISPLAY_URL}'\\n**Change:** '${CODE_URL}'\\n**External Release:**: '${RELEASE_LINK}'\\n**DockerHub:** '${DOCKERHUB_LINK}'\\n"}],\ "username": "Jenkins"}' ${BUILDS_DISCORD} ''' } } } cleanup { + sh '''#! /bin/bash + echo "Performing docker system prune!!" + containers=$(docker ps -aq) + if [[ -n "${containers}" ]]; then + docker stop ${containers} + fi + docker system prune -af --volumes || : + ''' cleanWs() } } diff --git a/README.md b/README.md index da0f80a..433c8d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -<!-- DO NOT EDIT THIS FILE MANUALLY --> -<!-- Please read the https://github.com/linuxserver/docker-nzbget/blob/master/.github/CONTRIBUTING.md --> - +<!-- DO NOT EDIT THIS FILE MANUALLY --> +<!-- Please read https://github.com/linuxserver/docker-nzbget/blob/master/.github/CONTRIBUTING.md --> [![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)](https://linuxserver.io) [![Blog](https://img.shields.io/static/v1.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=linuxserver.io&message=Blog)](https://blog.linuxserver.io "all the things you can do with our containers including How-To guides, opinions and much more!") @@ -27,10 +26,6 @@ Find us at: * [GitHub](https://github.com/linuxserver) - view the source for all of our repositories. * [Open Collective](https://opencollective.com/linuxserver) - please consider helping us by either donating or contributing to our budget -# DEPRECATION NOTICE - -This image is deprecated. We will not offer support for this image and it will not be updated. -nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd # [linuxserver/nzbget](https://github.com/linuxserver/docker-nzbget) [![Scarf.io pulls](https://scarf.sh/installs-badge/linuxserver-ci/linuxserver%2Fnzbget?color=94398d&label-color=555555&logo-color=ffffff&style=for-the-badge&package-type=docker)](https://scarf.sh/gateway/linuxserver-ci/docker/linuxserver%2Fnzbget) @@ -44,13 +39,13 @@ nzbget has been deprecated by its developers. Please consider switching to SABnz [![Jenkins Build](https://img.shields.io/jenkins/build?labelColor=555555&logoColor=ffffff&style=for-the-badge&jobUrl=https%3A%2F%2Fci.linuxserver.io%2Fjob%2FDocker-Pipeline-Builders%2Fjob%2Fdocker-nzbget%2Fjob%2Fmaster%2F&logo=jenkins)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-nzbget/job/master/) [![LSIO CI](https://img.shields.io/badge/dynamic/yaml?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=CI&query=CI&url=https%3A%2F%2Fci-tests.linuxserver.io%2Flinuxserver%2Fnzbget%2Flatest%2Fci-status.yml)](https://ci-tests.linuxserver.io/linuxserver/nzbget/latest/index.html) -[Nzbget](http://nzbget.net/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources. +[Nzbget](http://nzbget.com/) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources. -[![nzbget](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/nzbget-banner.png)](http://nzbget.net/) +[![nzbget](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/nzbget-banner.png)](http://nzbget.com/) ## Supported Architectures -We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/). +We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://distribution.github.io/distribution/spec/manifest-v2-2/#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/). Simply pulling `lscr.io/linuxserver/nzbget:latest` should retrieve the correct image for your arch, but you can also pull specific arch images via tags. @@ -60,36 +55,19 @@ The architectures supported by this image are: | :----: | :----: | ---- | | x86-64 | ✅ | amd64-\<version tag\> | | arm64 | ✅ | arm64v8-\<version tag\> | -| armhf| ✅ | arm32v7-\<version tag\> | - -## Version Tags - -This image provides various versions that are available via tags. Please read the descriptions carefully and exercise caution when using unstable or development tags. - -| Tag | Available | Description | -| :----: | :----: |--- | -| latest | ✅ | Stable nzbget releases | -| testing | ✅ | nzbget pre-releases | +| armhf | ❌ | | ## Application Setup -Webui can be found at `<your-ip>:6789` and the default login details (change ASAP) are +Webui can be found at `<your-ip>:6789` and the default login details (change ASAP) are `login:nzbget, password:tegbzn6789` To allow scheduling, from the webui set the time correction value in settings/logging. -To change umask settings. - -![](http://i.imgur.com/A4VMbwE.png) - -scroll to bottom, set umask like this (example shown for unraid) - -![](http://i.imgur.com/mIqDEJJ.png) - You can add an additional mount point for intermediate unpacking folder with:- -`-v </path/to/intermedia_unpacking_folder>:/intermediate` +`-v /path/to/nzbget/intermediate:/intermediate` for example, and changing the setting for InterDir in the PATHS tab of settings to `/intermediate` @@ -97,19 +75,18 @@ for example, and changing the setting for InterDir in the PATHS tab of settings We have set `/downloads` as a ***optional path***, this is because it is the easiest way to get started. While easy to use, it has some drawbacks. Mainly losing the ability to atomic move (TL;DR instant file moves, rather than copy+delete) files while processing content. -Use the optional paths if you dont understand, or dont want hardlinks/atomic moves. +Use the optional paths if you don't understand, or don't want hardlinks/atomic moves. The folks over at servarr.com wrote a good [write-up](https://wiki.servarr.com/docker-guide#consistent-and-well-planned-paths) on how to get started with this. ## Usage -Here are some example snippets to help you get started creating a container. +To help you get started creating a container from this image you can either use docker-compose or the docker cli. ### docker-compose (recommended, [click here for more info](https://docs.linuxserver.io/general/docker-compose)) ```yaml --- -version: "2.1" services: nzbget: image: lscr.io/linuxserver/nzbget:latest @@ -117,12 +94,12 @@ services: environment: - PUID=1000 - PGID=1000 - - TZ=Europe/London + - TZ=Etc/UTC - NZBGET_USER=nzbget #optional - NZBGET_PASS=tegbzn6789 #optional volumes: - - /path/to/data:/config - - /path/to/downloads:/downloads #optional + - /path/to/nzbget/data:/config + - /path/to/nzbget/downloads:/downloads #optional ports: - 6789:6789 restart: unless-stopped @@ -135,29 +112,29 @@ docker run -d \ --name=nzbget \ -e PUID=1000 \ -e PGID=1000 \ - -e TZ=Europe/London \ + -e TZ=Etc/UTC \ -e NZBGET_USER=nzbget `#optional` \ -e NZBGET_PASS=tegbzn6789 `#optional` \ -p 6789:6789 \ - -v /path/to/data:/config \ - -v /path/to/downloads:/downloads `#optional` \ + -v /path/to/nzbget/data:/config \ + -v /path/to/nzbget/downloads:/downloads `#optional` \ --restart unless-stopped \ lscr.io/linuxserver/nzbget:latest ``` ## Parameters -Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container. +Containers are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container. | Parameter | Function | | :----: | --- | | `-p 6789` | WebUI | | `-e PUID=1000` | for UserID - see below for explanation | | `-e PGID=1000` | for GroupID - see below for explanation | -| `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London. | +| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | | `-e NZBGET_USER=nzbget` | Specify the user for web authentication. | | `-e NZBGET_PASS=tegbzn6789` | Specify the password for web authentication. | -| `-v /config` | NZBGet App data. | +| `-v /config` | Persistent config | | `-v /downloads` | Location of downloads on disk. | ## Environment variables from files (Docker secrets) @@ -167,10 +144,10 @@ You can set any environment variable from a file by using a special prepend `FIL As an example: ```bash --e FILE__PASSWORD=/run/secrets/mysecretpassword +-e FILE__MYVAR=/run/secrets/mysecretvariable ``` -Will set the environment variable `PASSWORD` based on the contents of the `/run/secrets/mysecretpassword` file. +Will set the environment variable `MYVAR` based on the contents of the `/run/secrets/mysecretvariable` file. ## Umask for running applications @@ -179,15 +156,20 @@ Keep in mind umask is not chmod it subtracts from permissions based on it's valu ## User / Group Identifiers -When using volumes (`-v` flags) permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user `PUID` and group `PGID`. +When using volumes (`-v` flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user `PUID` and group `PGID`. Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic. -In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as below: +In this instance `PUID=1000` and `PGID=1000`, to find yours use `id your_user` as below: ```bash - $ id username - uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup) +id your_user +``` + +Example output: + +```text +uid=1000(your_user) gid=1000(your_user) groups=1000(your_user) ``` ## Docker Mods @@ -198,53 +180,100 @@ We publish various [Docker Mods](https://github.com/linuxserver/docker-mods) to ## Support Info -* Shell access whilst the container is running: `docker exec -it nzbget /bin/bash` -* To monitor the logs of the container in realtime: `docker logs -f nzbget` -* container version number - * `docker inspect -f '{{ index .Config.Labels "build_version" }}' nzbget` -* image version number - * `docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/nzbget:latest` +* Shell access whilst the container is running: + + ```bash + docker exec -it nzbget /bin/bash + ``` + +* To monitor the logs of the container in realtime: + + ```bash + docker logs -f nzbget + ``` + +* Container version number: + + ```bash + docker inspect -f '{{ index .Config.Labels "build_version" }}' nzbget + ``` + +* Image version number: + + ```bash + docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/nzbget:latest + ``` ## Updating Info -Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (ie. nextcloud, plex), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image. +Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (noted in the relevant readme.md), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image. Below are the instructions for updating containers: ### Via Docker Compose -* Update all images: `docker-compose pull` - * or update a single image: `docker-compose pull nzbget` -* Let compose update all containers as necessary: `docker-compose up -d` - * or update a single container: `docker-compose up -d nzbget` -* You can also remove the old dangling images: `docker image prune` +* Update images: + * All images: + + ```bash + docker-compose pull + ``` + + * Single image: + + ```bash + docker-compose pull nzbget + ``` + +* Update containers: + * All containers: + + ```bash + docker-compose up -d + ``` + + * Single container: + + ```bash + docker-compose up -d nzbget + ``` + +* You can also remove the old dangling images: + + ```bash + docker image prune + ``` ### Via Docker Run -* Update the image: `docker pull lscr.io/linuxserver/nzbget:latest` -* Stop the running container: `docker stop nzbget` -* Delete the container: `docker rm nzbget` -* Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and settings will be preserved) -* You can also remove the old dangling images: `docker image prune` +* Update the image: + + ```bash + docker pull lscr.io/linuxserver/nzbget:latest + ``` -### Via Watchtower auto-updater (only use if you don't remember the original parameters) +* Stop the running container: -* Pull the latest image at its tag and replace it with the same env variables in one run: + ```bash + docker stop nzbget + ``` - ```bash - docker run --rm \ - -v /var/run/docker.sock:/var/run/docker.sock \ - containrrr/watchtower \ - --run-once nzbget - ``` +* Delete the container: -* You can also remove the old dangling images: `docker image prune` + ```bash + docker rm nzbget + ``` + +* Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and settings will be preserved) +* You can also remove the old dangling images: -**Note:** We do not endorse the use of Watchtower as a solution to automated updates of existing Docker containers. In fact we generally discourage automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, we highly recommend using [Docker Compose](https://docs.linuxserver.io/general/docker-compose). + ```bash + docker image prune + ``` ### Image Update Notifications - Diun (Docker Image Update Notifier) -* We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported. +**tip**: We recommend [Diun](https://crazymax.dev/diun/) for update notifications. Other tools that automatically update containers unattended are not recommended or supported. ## Building locally @@ -269,6 +298,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **09.05.24:** - Revive image based on the fork from https://github.com/nzbgetcom/nzbget * **31.12.22:** - Deprecate image. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd * **27.11.22:** - Advanced notice: This image will be deprecated on 2022-12-31. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd * **13.11.22:** - Rebase master to 3.16, migrate to s6v3. @@ -301,4 +331,4 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 * **09.09.16:** - Add layer badges to README. * **27.08.16:** - Add badges to README, perms fix on /app to allow updates. * **19.08.16:** - Rebase to alpine linux. -* **18.08.15:** - Now useing latest version of unrar beta and implements the universal installer method. +* **18.08.15:** - Now using latest version of unrar beta and implements the universal installer method. diff --git a/jenkins-vars.yml b/jenkins-vars.yml index 6c7db8e..890270a 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -7,8 +7,7 @@ release_type: stable release_tag: latest ls_branch: master repo_vars: - - EXT_GIT_BRANCH = 'master' - - EXT_USER = 'nzbget' + - EXT_USER = 'nzbgetcom' - EXT_REPO = 'nzbget' - BUILD_VERSION_ARG = 'NZBGET_RELEASE' - LS_USER = 'linuxserver' @@ -23,9 +22,9 @@ repo_vars: - CI_WEB='true' - CI_PORT='6789' - CI_SSL='false' - - CI_DELAY='120' - - CI_DOCKERENV='TZ=US/Pacific' + - CI_DELAY='60' + - CI_DOCKERENV='' - CI_AUTH='nzbget:tegbzn6789' - CI_WEBPATH='' sponsor_links: - - { name: "NZBGet", url: "https://nzbget.net/donate" } + - { name: "NZBGet", url: "https://nzbget.com/donate/" } diff --git a/readme-vars.yml b/readme-vars.yml index 0fb8078..7769a58 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -2,21 +2,15 @@ # project information project_name: nzbget -project_url: "http://nzbget.net/" +project_url: "http://nzbget.com/" project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/nzbget-banner.png" project_blurb: "[{{ project_name|capitalize }}]({{ project_url }}) is a usenet downloader, written in C++ and designed with performance in mind to achieve maximum download speed by using very little system resources." project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}" -project_blurb_optional_extras_enabled: false - -# deprecation information -project_deprecation_status: true -project_deprecation_message: "nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd" # supported architectures available_architectures: - { arch: "{{ arch_x86_64 }}", tag: "amd64-latest"} - { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"} - - { arch: "{{ arch_armhf }}", tag: "arm32v7-latest"} # development version development_versions: true @@ -27,21 +21,18 @@ development_versions_items: # container parameters common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" -param_usage_include_net: false + param_usage_include_env: true -param_env_vars: - - { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London." } param_usage_include_vols: true param_volumes: - - { vol_path: "/config", vol_host_path: "/path/to/data", desc: "NZBGet App data." } + - { vol_path: "/config", vol_host_path: "/path/to/nzbget/data", desc: "Persistent config" } opt_param_usage_include_vols: true opt_param_volumes: - - { vol_path: "/downloads", vol_host_path: "/path/to/downloads", desc: "Location of downloads on disk." } + - { vol_path: "/downloads", vol_host_path: "/path/to/nzbget/downloads", desc: "Location of downloads on disk." } param_usage_include_ports: true param_ports: - { external_port: "6789", internal_port: "6789", port_desc: "WebUI" } -param_device_map: false -cap_add_param: false + # optional container parameters # optional variables @@ -49,31 +40,19 @@ opt_param_usage_include_env: true opt_param_env_vars: - { env_var: "NZBGET_USER", env_value: "nzbget", desc: "Specify the user for web authentication."} - { env_var: "NZBGET_PASS", env_value: "tegbzn6789", desc: "Specify the password for web authentication."} -opt_param_usage_include_ports: false -opt_param_device_map: false -opt_cap_add_param: false -optional_block_1: false # application setup block app_setup_block_enabled: true app_setup_block: | - Webui can be found at `<your-ip>:6789` and the default login details (change ASAP) are + Webui can be found at `<your-ip>:6789` and the default login details (change ASAP) are `login:nzbget, password:tegbzn6789` To allow scheduling, from the webui set the time correction value in settings/logging. - To change umask settings. - - ![](http://i.imgur.com/A4VMbwE.png) - - scroll to bottom, set umask like this (example shown for unraid) - - ![](http://i.imgur.com/mIqDEJJ.png) - You can add an additional mount point for intermediate unpacking folder with:- - `-v </path/to/intermedia_unpacking_folder>:/intermediate` + `-v /path/to/nzbget/intermediate:/intermediate` for example, and changing the setting for InterDir in the PATHS tab of settings to `/intermediate` @@ -81,42 +60,10 @@ app_setup_block: | We have set `/downloads` as a ***optional path***, this is because it is the easiest way to get started. While easy to use, it has some drawbacks. Mainly losing the ability to atomic move (TL;DR instant file moves, rather than copy+delete) files while processing content. - Use the optional paths if you dont understand, or dont want hardlinks/atomic moves. + Use the optional paths if you don't understand, or don't want hardlinks/atomic moves. The folks over at servarr.com wrote a good [write-up](https://wiki.servarr.com/docker-guide#consistent-and-well-planned-paths) on how to get started with this. # changelog changelogs: - - { date: "31.12.22:", desc: "Deprecate image. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd" } - - { date: "27.11.22:", desc: "Advanced notice: This image will be deprecated on 2022-12-31. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd" } - - { date: "13.11.22:", desc: "Rebase master to 3.16, migrate to s6v3." } - - { date: "12.08.22:", desc: "Bump unrar to 6.1.7." } - - { date: "22.02.22:", desc: "Rebase to alpine 3.15, add six and python 7zip tools, allow env variables for credentials." } - - { date: "04.07.21:", desc: "Rebase to alpine 3.14." } - - { date: "28.05.21:", desc: "Add linuxserver wheel index." } - - { date: "23.01.21:", desc: "Rebasing to alpine 3.13." } - - { date: "26.10.20:", desc: "Fix python dependencies." } - - { date: "24.08.20:", desc: "Fix ignored umask environment variable." } - - { date: "08.06.20:", desc: "Symlink python3 bin to python." } - - { date: "01.06.20:", desc: "Rebasing to alpine 3.12. Removing python2." } - - { date: "13.05.20:", desc: "Add rarfile python package (for DeepUnrar)." } - - { date: "01.01.20:", desc: "Add python3 alongside python2 during transition." } - - { date: "19.12.19:", desc: "Rebasing to alpine 3.11." } - - { date: "28.06.19:", desc: "Rebasing to alpine 3.10." } - - { date: "13.06.19:", desc: "Add apprise, chardet & pynzbget packages." } - - { date: "23.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." } - - { date: "25.02.19:", desc: "Rebasing to alpine 3.9." } - - { date: "20.01.19:", desc: "Add pipeline logic and multi arch, build from source." } - - { date: "21.08.18:", desc: "Rebase to alpine 3.8." } - - { date: "20.02.18:", desc: "Add note about supplemental mount point for intermediate unpacking." } - - { date: "13.12.17:", desc: "Rebase to alpine 3.7." } - - { date: "02.09.17:", desc: "Place app in subfolder rather than /app." } - - { date: "12.07.17:", desc: "Add inspect commands to README, move to jenkins build and push." } - - { date: "28.05.17:", desc: "Rebase to alpine 3.6." } - - { date: "20.04.17:", desc: "Add testing branch." } - - { date: "06.02.17:", desc: "Rebase to alpine 3.5." } - - { date: "30.09.16:", desc: "Fix umask." } - - { date: "09.09.16:", desc: "Add layer badges to README." } - - { date: "27.08.16:", desc: "Add badges to README, perms fix on /app to allow updates." } - - { date: "19.08.16:", desc: "Rebase to alpine linux." } - - { date: "18.08.15:", desc: "Now useing latest version of unrar beta and implements the universal installer method." } + - { date: "09.05.24:", desc: "Revive image based on the fork from https://github.com/nzbgetcom/nzbget" } diff --git a/root/donate.txt b/root/donate.txt index 6d16580..8dfbded 100755 --- a/root/donate.txt +++ b/root/donate.txt @@ -1 +1 @@ -NZBGet: https://nzbget.net/donate +NZBGet: https://nzbget.com/donate/ diff --git a/root/etc/cont-init.d/99-deprecation b/root/etc/cont-init.d/99-deprecation deleted file mode 100755 index a24491b..0000000 --- a/root/etc/cont-init.d/99-deprecation +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/with-contenv bash - -echo ' -****************************************************** -****************************************************** -* * -* * -* This image is deprecated. * -* We will not offer support for this image * -* and it will not be updated. * -* * -* * -****************************************************** -****************************************************** - -nzbget has been deprecated by its developers. Please consider switching to SABnzbd https://github.com/linuxserver/docker-sabnzbd - -****************************************************** -******************************************************' diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/run b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/run index 4535ce2..d530339 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/run @@ -1,4 +1,5 @@ #!/usr/bin/with-contenv bash +# shellcheck shell=bash if [[ ! -d /downloads ]]; then mkdir -p /downloads @@ -17,8 +18,10 @@ fi # permissions lsiown abc:abc \ /downloads -lsiown abc:abc -R \ + +lsiown -R abc:abc \ /app/nzbget \ /config + chmod u+rw \ /config/nzbget.conf diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/type b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/type index 3d92b15..bdd22a1 100644 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/type +++ b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/type @@ -1 +1 @@ -oneshot \ No newline at end of file +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/up b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/up index 71f3f31..63cd084 100644 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/up +++ b/root/etc/s6-overlay/s6-rc.d/init-nzbget-config/up @@ -1 +1 @@ -/etc/s6-overlay/s6-rc.d/init-nzbget-config/run \ No newline at end of file +/etc/s6-overlay/s6-rc.d/init-nzbget-config/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/dependencies.d/legacy-services b/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/dependencies.d/legacy-services deleted file mode 100644 index e69de29..0000000 diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/run b/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/run deleted file mode 100755 index c51bc35..0000000 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/run +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -echo ' -****************************************************** -****************************************************** -* * -* * -* This image will be deprecated on 2022-12-31. * -* * -* * -****************************************************** -****************************************************** - -nzbget has been deprecated by its developers. -Please consider switching to SABnzbd -https://github.com/linuxserver/docker-sabnzbd - -****************************************************** -******************************************************' diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/type b/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/type deleted file mode 100644 index 3d92b15..0000000 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/type +++ /dev/null @@ -1 +0,0 @@ -oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/up b/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/up deleted file mode 100644 index 834a13d..0000000 --- a/root/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/s6-rc.d/init-nzbget-deprecation/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nzbget/run b/root/etc/s6-overlay/s6-rc.d/svc-nzbget/run index 535c55d..96137e8 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-nzbget/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-nzbget/run @@ -1,12 +1,14 @@ #!/usr/bin/with-contenv bash +# shellcheck shell=bash # parse env vars to options OPTIONS="" if [[ ${NZBGET_USER} && ${NZBGET_USER-x} ]]; then - OPTIONS+="-o ControlUsername=${NZBGET_USER} " + OPTIONS+="-o ControlUsername=${NZBGET_USER} " fi + if [[ ${NZBGET_PASS} && ${NZBGET_PASS-x} ]]; then - OPTIONS+="-o ControlPassword=${NZBGET_PASS} " + OPTIONS+="-o ControlPassword=${NZBGET_PASS} " fi exec \ diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nzbget/type b/root/etc/s6-overlay/s6-rc.d/svc-nzbget/type index 1780f9f..5883cff 100644 --- a/root/etc/s6-overlay/s6-rc.d/svc-nzbget/type +++ b/root/etc/s6-overlay/s6-rc.d/svc-nzbget/type @@ -1 +1 @@ -longrun \ No newline at end of file +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/user2/contents.d/init-nzbget-deprecation b/root/etc/s6-overlay/s6-rc.d/user2/contents.d/init-nzbget-deprecation deleted file mode 100644 index e69de29..0000000