Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional artifact check via external_artifact_check in jenkins_vars.yml #283

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

aptalca
Copy link
Member

@aptalca aptalca commented Sep 5, 2024

A few images use a custom external trigger to check for upstream artifacts before triggering a new build. However, once switched over to custom, the whole external trigger is manually managed and any update to the template requires manual updates to the custom ones.

This PR adds the external artifact check into the template, activated a new block var in jenkins-vars.yml named external_artifact_check.

This var can be set to any multiline bash commands (written in the jinja/ansible template style) and it will be injected into the external trigger.
The only requirement is that the var sets artifacts_found to either true or false depending on whatever check needs to be performed.

A sample var for Emby is as follows:

external_artifact_check: |
  assets=$(curl -u "${{ '{{' }} secrets.CR_USER {{ '}}' }}:${{ '{{' }} secrets.CR_PAT {{ '}}' }}" -sX GET "https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/tags/${EXT_RELEASE}" | jq -r '.assets[].browser_download_url')
  if grep -q "emby-server-deb_${EXT_RELEASE}_arm64.deb$" <<< "${assets}" && grep -q "emby-server-deb_${EXT_RELEASE}_amd64.deb$" <<< "${assets}"; then
    artifacts_found="true"
  else
    artifacts_found="false"
  fi

This block gets entered into the external trigger as shown here:
https://github.com/linuxserver/docker-emby/blob/bfa7d0bf3c127146ec5e7209cb6eadd5079b9952/.github/workflows/external_trigger.yml#L80-L85
As you can see, the github workflow variables such as ${{ secrets.CR_USER }} need to be entered into jenkins-vars.yml as ${{ '{{' }} secrets.CR_USER {{ '}}' }} because they go through jinja/ansible templating.

Here's the output of the test trigger: https://github.com/linuxserver/docker-emby/actions/runs/10725065218 (it was manually adjusted to force triggering even on the same version)
Here's the output of the test trigger with artifact check failed intentionally: https://github.com/linuxserver/docker-emby/actions/runs/10725987059

@aptalca aptalca requested a review from a team September 5, 2024 17:27
@LinuxServer-CI
Copy link
Contributor

I am a bot, here are the test results for this PR:
https://ci-tests.linuxserver.io/lspipepr/jenkins-builder/1c444d00-pkg-1c444d00-dev-603c50c3583dab079313c667111347b6fc1e86e2-pr-283/index.html
https://ci-tests.linuxserver.io/lspipepr/jenkins-builder/1c444d00-pkg-1c444d00-dev-603c50c3583dab079313c667111347b6fc1e86e2-pr-283/shellcheck-result.xml

Tag Passed
amd64-1c444d00-pkg-1c444d00-dev-603c50c3583dab079313c667111347b6fc1e86e2-pr-283
arm64v8-1c444d00-pkg-1c444d00-dev-603c50c3583dab079313c667111347b6fc1e86e2-pr-283

@LinuxServer-CI
Copy link
Contributor

I am a bot, here are the test results for this PR:
https://ci-tests.linuxserver.io/lspipepr/jenkins-builder/1c444d00-pkg-1c444d00-dev-9b1ac5e7372a1f53a45a58fddad2178344add5d1-pr-283/index.html
https://ci-tests.linuxserver.io/lspipepr/jenkins-builder/1c444d00-pkg-1c444d00-dev-9b1ac5e7372a1f53a45a58fddad2178344add5d1-pr-283/shellcheck-result.xml

Tag Passed
amd64-1c444d00-pkg-1c444d00-dev-9b1ac5e7372a1f53a45a58fddad2178344add5d1-pr-283
arm64v8-1c444d00-pkg-1c444d00-dev-9b1ac5e7372a1f53a45a58fddad2178344add5d1-pr-283

@aptalca aptalca merged commit e95e0d9 into monthly Sep 6, 2024
4 checks passed
@aptalca aptalca deleted the monthly-external branch September 6, 2024 15:54
@aptalca aptalca mentioned this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants